#include <stdio.h>
int main() {
int a, b, m, n, d;
scanf("%d %d",&a,&b);
int arr1[1000] = {0};
int arr2[1000] = {0};
int arr3[1000] = {0};
for(int i = 0;i<a;i++)
{
scanf("%d",&arr1[i]);
}
for(int i = 0;i<b;i++)
{
scanf("%d",&arr2[i]);
}
for(m = 0,n = 0,d = 0;d<a+b;d++)
{
if(m<a && n<b)
{
if(arr1[m]<arr2[n])
{
arr3[d] = arr1[m];
m++;
}
else if(arr1[m]>arr2[n])
{
arr3[d] = arr2[n];
n++;
}
else if(arr1[m] == arr2[n])
{
arr3[d] = arr1[m];
m++;
}
}
else if(m>=a)
{
arr3[d] = arr2[n];
n++;
}
else if(n>=b)
{
arr3[d] = arr1[m];
m++;
}
}
for(int i = 0;i<a+b;i++)
{
printf("%d ",arr3[i]);
}
return 0;
}