#include <stdio.h>
#include <string.h>
int main() {
    int a, b;
    int m[1000],n[1000];
    int he[2000];
    int i,j;
    int temp=0;
    scanf("%d %d", &a, &b);
    for(i=0;i<a;i++)
    {
        scanf("%d",&m[i]);
    }
    for(j=0;j<b;j++)
    {
        scanf("%d",&n[j]);
    }
    for(i=0;i<a;i++)
    {
       he[i]=m[i];
    }
    for(j=0;j<b;j++)
    {
        he[i+j]=n[j];
    }
    for(int k=0;k<(a+b);k++)
    {
       for(int l=k+1;l<(a+b);l++)
       {
            if(he[k]>he[l])
            {
                temp=he[k];
                he[k]=he[l];
                he[l]=temp;
            }
       }
       printf("%d ",he[k]);
    }

    return 0;
}