#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

struct Node {
    char name[101];
    struct Node* next;
};

struct Node* head = NULL;
struct Node* tail = NULL; 
int isValidName(char* name) {
    for (int i = 0; name[i] != '\0'; i++) {
        if (!isalnum(name[i])) {
            return 0;
        }
    }
    return 1;
}
void addVisitor(char* name) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    strcpy(newNode->name, name);
    newNode->next = NULL;

    if (head == NULL) {
        head = tail = newNode;
    } else {
        tail->next = newNode;
        tail = newNode;
    }
}
void printVisitors() {
    struct Node* temp = head;
    while (temp != NULL) {
        printf("%s", temp->name);
        if (temp->next != NULL) printf(" ");
        temp = temp->next;
    }
}

int main() {
    int n;
    scanf("%d", &n);
    char name[101];

    int invalid = 0;

    for (int i = 0; i < n; i++) {
        scanf("%s", name);
        if (!isValidName(name)) {
            invalid = 1;
            break;
        }
        addVisitor(name);
    }

    if (invalid) {
        printf("Invalid input");
    } else {
        printVisitors();
    }

return0;
}