#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
struct Node {
    int name[100];
    struct Node* next;
};
struct Node* head=NULL;
int isValid(char name[]){
    for (int i=0;i<strlen(name);i++) {
        if (!isalnum(name[i])) {
            return 0;
        }
    }
    return 1;
}
void insert(char name[]) {
    struct Node* newnode=(struct Node*)malloc(sizeof(struct Node));
    if (!newnode){
        exit(1);
    }
    strcpy(int newnode->name,name);
    newnode->next=NULL;
    if (head==NULL){
        head=newnode;
    } 
    else{
        struct Node* current=head;
        while (current->next!=NULL) {
            current=current->next;
        }
        current->next=newnode;
    }
}

int createList(int n){
    int valid=1;
    for (int i=0;i<n;i++){
        char name[101];
        scanf("%s", name);
        if (!isValid(name)) {
            valid = 0;
        }
        insert(name);
    }
    return valid;
}
void printList(){
    struct Node* current=head;
    while (current != NULL){
        printf("%s", current->name);
        if (current->next != NULL) printf(" ");
        current=current->next;
    }
    printf("\n");
}
int main(){
    int n;
    scanf("%d",&n);
    int valid=createList(n);
    if (!valid) {
        printf("Invalid input\n");
    } 
    else {
        printList();
    }
    return 0;
}