#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

struct node {
    char data[101];
    struct node *next;
};

int isValidName(char *s) {
    for (int i = 0; s[i] != '\0'; i++) {
        if (!isalpha(s[i])) {   // only alphabets allowed
            return 0;
        }
    }
    return 1;
}

int main() {
    int n;
    scanf("%d", &n);

    if (n < 1 || n > 1000) {
        printf("Invalid Input");
        return 0;
    }

    struct node *head = NULL, *tail = NULL, *p;
    char temp[101];

    for (int i = 0; i < n; i++) {
        scanf("%s", temp);

        // check invalid input (special chars/digits)
        if (!isValidName(temp)) {
            printf("Invalid Input");
            return 0;
        }

        struct node newNode = (struct node)malloc(sizeof(struct node));
        strcpy(newNode->data, temp);
        newNode->next = NULL;

        if (head == NULL) {
            head = newNode;
            tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;   // move tail
        }
    }

    // print names in order
    p = head;
    while (p != NULL) {
        printf("%s", p->data);
        if (p->next != NULL) printf(" ");
        p = p->next;
    }

    return 0;
}