#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_NAME_LENGTH 100
#define MAX_VISITORS 1000

typedef struct Node {
    char name[MAX_NAME_LENGTH];
    struct Node* next;
} Node;

void add_to_tail(Node** head, Node** tail, const char* name) {
    Node* new_node = (Node*)malloc(sizeof(Node));
    if (!new_node) {
        printf("Invalid input\n");
        exit(1);
    }
    strcpy(new_node->name, name);
    new_node->next = NULL;

    if (*tail == NULL) {
        *head = *tail = new_node;
    } else {
        (*tail)->next = new_node;
        *tail = new_node;
    }
}

void print_list(Node* head) {
    Node* current = head;
    int first = 1;
    while (current) {
        if (!first) {
            printf(" ");
        }
        printf("%s", current->name);
        first = 0;
        current = current->next;
    }
    printf("\n");
}

int contains_special_char(const char* str) {
    const char* special_chars = "!@#$%^&*()-_=+[]{};:'\",<.>/?`~";
    while (*str) {
        if (strchr(special_chars, *str)) {
            return 1;
        }
        str++;
    }
    return 0;
}

int main() {
    int n;
    if (scanf("%d\n", &n) != 1 || n < 1 || n > MAX_VISITORS) {
        printf("Invalid input\n");
        return 1;
    }

    Node* head = NULL;
    Node* tail = NULL;

    for (int i = 0; i < n; i++) {
        char name[MAX_NAME_LENGTH];
        if (fgets(name, sizeof(name), stdin) == NULL) {
            printf("Invalid input\n");
            return 1;
        }
        name[strcspn(name, "\n")] = 0;                  

        if (contains_special_char(name)) {
            printf("// Remove newline

        if (contains_special_char(name)) {
            printf("Invalid input\n");
            return 1;
        }

        add_to_tail(&head, &tail, name);
    }

    print_list(head);

    // Free allocated memory
    while (head) {
        Node* temp = head;
        head = head->next;
        free(temp);
    }

    return 0;
}