#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node 
{
    char s[100];
    struct node* next;
};

struct node* createnode(char s1[])
{
    struct node* newnode = (struct node*)malloc(sizeof(struct node));
    strcpy(newnode->s, s1);
    newnode->next = NULL;
    return newnode;
}

int main() 
{
    int n;
    scanf("%d", &n);

    struct node *head = NULL, *tail = NULL;

    for (int i = 0; i < n; i++)
    {
        char temp[100];
        scanf("%s", temp);

        struct node* newnode = createnode(temp);
        int j;
        for(j=0;newnode->s[j]!='\0';j++)
        {
            char ch=newnode->s[j];
            if(!((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')||(ch>='0'&&ch<='9')))
            {
                printf("Invalid input");
                return 0;
            }
        }
        if (head == NULL) 
        {
            head = tail = newnode;
        } else 
            tail->next = newnode;
            tail = newnode;
        }
    }

    struct node* current = head;
    while (current != NULL)
    {
        printf("%s", current->s);
        if (current->next != NULL)
        {
            printf(" ");
        }
        current = current->next;
    }
    printf("\n");

    current = head;
    while (current != NULL)
    {
        struct node* temp = current;
        current = current->next;
        free(temp);
    }

    return 0;
}