#include <stdio.h>
#include <string.h>

#define NUM_NAMES 100
#define NAME_SIZE 26 

void printNames(char lastNames[][NAME_SIZE], char firstNames[][NAME_SIZE], int i)
{
    int j = 0;
    while(j < i) {
        printf("%s, %s\n", lastNames[j], firstNames[j]);
        j++;
    }
}
int main(void)
{
    char firstNames[NUM_NAMES][NAME_SIZE];
    char lastNames[NUM_NAMES][NAME_SIZE];
    char name[NAME_SIZE];
    int i = 0;

    scanf("%s", name);
    while(i < NUM_NAMES && strcmp("Done", name) != 0) {
        strcpy(firstNames[i], name);
        scanf("%s", name);
        strcpy(lastNames[i], name);
        i++;
        scanf("%s", name);
    }
    printNames(lastNames, firstNames, i);
    return 0;
}