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