#include<stdio.h>
struct node
{
char data;
node* lchild;
node* rchild;
};
node* newnode(char b)
{
struct node* Node= new node;
Node->data=b;
Node->lchild=Node->rchild=NULL;
return Node;
}
void insert(struct node* &root,char a[4])
{
if(root==NULL) return;
if(root->data==a[0])
{
root->lchild=newnode(a[1]);
root->rchild=newnode(a[2]);
return;
}
else
{
insert(root->lchild,a);
insert(root->rchild,a);
}
}
struct node* creat(char a[][4],int n)
{
struct node* rot=new node;
for(int i=0;i<n;i++)
{
if(i==0) rot->data=a[0][0];
insert(rot,a[i]);
}
return rot;
}
void preorder(struct node* root)
{
if(root->data=='*') return;
printf("%c",root->data);
preorder(root->lchild);
preorder(root->rchild);
}
int n;
int main()
{
scanf("%d",&n);
char c=getchar();
char a[30][4];
struct node* Root =NULL;
for(int i=0;i<n;i++)
{
for(int j=0;j<4;j++)
{
scanf("%c",&a[i][j]);
}
}
Root=creat(a,n);
preorder(Root);
return 0;
}