/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press “Run” button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
void accept(int set[],int n)
{
for(int i=0;i<n;i++)
{
scanf("%d",&set[i]);
}
}
int uni(int set1[],int n1,int set2[],int n2,int set3[])
{
int n3=0,j;
for(int i=0;i<n1;i++)
{
set3[i]=set1[i];
}
n3=n1;
for(int i=0;i<n2;i++)
{
for(j=0;j<n1;j++)
{
if(set1[j]==set2[i])
{
break;
}
}
if(j==n1)
{
set3[n3]=set2[i];
n3++;
}
}
return n3;
}
void display(int set[],int n)
{
printf("{");
for(int i=0;i<n;i++)
{
if(i<(n-1))
printf(" %d ",set[i]);
else
printf(" %d ",set[i]);
}
printf("}");
}
int main()
{
int n1,n2,n3;
scanf("%d",&n1);
scanf("%d",&n2);
int set1[n1],set2[n2],set3[n3];
accept(set1,n1);
accept(set2,n2);
uni(set1,n1,set2,n2,set3);
display(set3,n3);
return 0;
}