#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define DATA
typedef struct Node {
    char name[DATA];
    struct Node* next;
} Node;
int isValid(char *s) {
    for (int i = 0; s[i]; i++)
        if (!isalpha(s[i]))
            return 0;
    return 1;
}
int main() {
    int n;
    if (scanf("%d", &n) != 1 || n < 1 || n > 1000) {
        printf("Invalid input\n");
        return 0;
    }

    Node *head = NULL, *tail = NULL;

    for (int i = 0; i < n; i++) {
        char temp[D];
        if (scanf("%100s", temp) != 1 || !isValid(temp)) {
            printf("Invalid input\n");
            while (head) {
                Node* tmp = head;
                head = head->next;
                free(tmp);
            }
            return 0;
        }
        Node* newNode = (Node*)malloc(sizeof(Node));
        strcpy(newNode->name, temp);
        newNode->next = NULL;
        if (!head) {
            head = tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }
    Node* current = head;
    while (current) {
        printf("%s", current->name);
        if (current->next) printf(" ");
        current = current->next;
    }
    printf("\n");
    while (head) {
        Node* tmp = head;
        head = head->next;
        free(tmp);
    }

    return 0;
}