// editor2
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
struct Node
{
    char data[50];
    struct Node *next;
    struct Node *prev;
};
struct Node *create(char data[50])
{
    struct Node *newnode=(struct Node*)malloc(sizeof(struct Node));
    strcpy(newnode->data,data);
    newnode->next=NULL;
    newnode->prev=NULL;
    return newnode;
}
void insert(char data[50],struct Node **head)
{
    struct Node *newnode=create(data),*temp=*head;
    if(*head==NULL)
    {
        *head=newnode;
    }
    else
    {
        while(temp->next!=NULL)
        {
            temp=temp->next;
        }
        temp->next=newnode;
        newnode->prev=temp;
    }
}
void print(struct Node *temp)
{
    while(temp!=NULL)
    {
        printf("%s",temp->data);
        temp=temp->next;
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    struct Node *head;
    for(int i=0;i<n;i++)
    {
        char data[50];
        scanf("%s",data);
        for(int j=0;j<strlen(data);j++)
        {
            if(isalnum(data[j]))
            {
                printf("Invalid input");
                return 0;
            }
        }
        insert(data,&head);
    }
    void print(head);
}