#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct Node {
    char message[101];
    struct Node* prev;
    struct Node* next;
} Node;

int containsDigit(char* str) {
    for (int i = 0; str[i] != '\0'; i++) {
        if (isdigit(str[i])) return 1;
    }
    return 0;
}

Node* createNode(char* msg) {
    Node* newNode = (Node*)malloc(sizeof(Node));
    strcpy(newNode->message, msg);
    newNode->prev = newNode->next = NULL;
    return newNode;
}

void append(Node** head, Node** tail, char* msg) {
    Node* newNode = createNode(msg);
    if (*head == NULL) {
        *head = *tail = newNode;
    } else {
        (*tail)->next = newNode;
        newNode->prev = *tail;
        *tail = newNode;
    }
}
void display(Node* head) {
    Node* temp = head;
    while (temp != NULL) {
        printf("%s\n", temp->message);
        temp = temp->next;
    }
}
int main() {
    int n;
    scanf("%d", &n);

    Node* head = NULL;
    Node* tail = NULL;

    char buffer[101];
    for (int i = 0; i < n; i++) {
        scanf("%s", buffer);
        if (containsDigit(buffer)) {
            printf("Invalid input\n");
            return 0;
        }
        append(&head, &tail, buffer);
    }
    display(head);
    return 0;
}
app