#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct Node{
    char name[100];
    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 addVistor(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 printVistors() {
    
    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);
    int valid = 0;
    for(int i=0;i<n;i++){
        char name[100];
        scanf("%s", name);
        if(!isValidName(name)) {
            valid = 1;
        }
        addVistor(name);
    }
    if (invalid) {
        printf("Invalid input");
    }else {
        printVistors();
    }
    return 0;
}