// editor2
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
    char data;
    struct node *left,*right;
}Node;

Node *root =NULL;

Node* create(int num)
{
    Node *newNode =(Node*)malloc(sizeof(Node)) ;
    newNode->data=num;
    newNode->left=NULL;
    newNode->right=NULL;
    return newNode;
}

Node* inser(Node *root,int num)
{
    if(root==NULL)
        return create(num);
    if(num<root->data)
        root->left=inser(root->left,num);
    else if(num>root->data)
        root->right=inser(root->right,num);
        return root;
}
void preOrder(Node *root)
{
    if(root!=NULL)
    {
        printf("%c ",root->data);
        preOrder(root->left);
        preOrder(root->right);
        
    }
    
}
void postOrder(Node *root)
{
    if(root!=NULL)
    {
    
        postOrder(root->left);
        postOrder(root->right);
        printf("%c ",root->data);
        
    }
}
void InOrder(Node *root)
{
    if(root!=NULL)
    {
    
        InOrder(root->left);
          printf("%c ",root->data);
        InOrder(root->right);
      
     
        
    }
}
int main()
{
    int size,itr,num;
    scanf("%d",&size);
    if(size<0)
    {
        printf("Invalid input");
        return 0;
    }
    getchar();
    for(itr=1;itr<=size*2;itr++)
    {
        scanf("%d",&num);
        if(num=='')
        continue;
        root = inser(root,num);
    }
    InOrder(root);
    return 0;
}