#include <stdio.h>
int a[20],b[20],c[40];
int main()
{
int n1,n2,i;
scanf("%d%d",&n1,&n2);
for(i=0;i<n1;i++)
scanf("%d",&a[i]);
for(i=0;i<n2;i++)
scanf("%d",&b[i]);
int pa = 0;
int pb = 0;
do
{
if(a[pa] < b[pb])
{
printf("%d ",a[pa]);
pa++;
}
if(a[pa]>b[pb])
{
printf("%d ",b[pb]);
pb++;
}
if(a[pa]==b[pb])
{
printf("%d ",b[pb]);
pb++;
pa++;
}
}while(pa != n1 && pb != n2);
if(pa == n1)
{
for(i=pb;i<n2;i++)
{
printf("%d",b[i]);
if(i != n2 - 1)
printf(" ");
}
}
if(pb==n2)
{
for(i=pa;i<n1;i++)
{
printf("%d",a[i]);
if(i != n1-1)
printf(" ");
}
}
return 0;
}