#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct Node {
    char name[101];
    struct Node *next;
};
int main() 
 {
    int n, i, j, valid = 1;
    scanf("%d", &n);
    struct Node *head = NULL, *tail = NULL;
    for (i = 0; i < n; i++) {
        char temp[101];
        scanf("%s", temp);
        for (j = 0; temp[j] != '\0'; j++) {
            if (!isalpha(temp[j])) {
                valid = 0;
                break;
            }
        }
        if (!valid) break;
        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;
        }
    }

    if (!valid) {
        printf("Invalid input");
    } else 
{    
        struct Node *curr = head;
        while (curr != NULL) {
            printf("%s", curr->name);
            if (curr->next != NULL)
            {printf(" ");
            curr = curr->next;

        }
    }
}
    return 0;
 }