#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
struct Node {
    char name[101];
    struct Node *next;
};

int isValidName(char *Name){
    for (int i = 0; Name[i] != '\0'; i++){
        if (!isalpha(Name[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 (!isValidName(temp)){
            printf("Ivalid 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 *current = head;
    while (current != NULL){
        printf("%s", current->name);
        if (current->next)!= NULL){
            printf(" ");
        }
        current = current->next;
    }
    printf("\n");
    
    return 0;
    
}