#include <stdio.h>

int main() {
    int arr1[1001] = {0},arr2[1001] = {0},arr3[1001] = {0};
    int n = 0,m = 0;
    scanf("%d %d",&n,&m);
  //录取两个数组
    for(int i=0; i<n; i++)
    {
        scanf("%d",&arr1[i]);
    }
    for(int i=0; i<m; i++)
    {
        scanf("%d",&arr2[i]);
    }
    

    int b = 0;
    int i = 0,j = 0;
  //比较两个数组元素大小
    while(i<n&&j<m)
    {
        if(arr1[i]>arr2[j])
        {
            arr3[b++] = arr2[j++];
        }
        else{
            arr3[b++] = arr1[i++];
        }
    }
  //将剩余数组元素拷贝给新数组
    if(i==n)
    {
        for(int i = j;i<=m;i++)
        {
            arr3[b++] = arr2[i];
        }
    }
    else {
        for(int j = i;j<=n;j++)
        {
            arr3[b++] = arr1[j];
        }
    }
    for(int i = 0;i<m+n;i++)//打印数组
    {
        printf("%d ",arr3[i]);
    }
    return 0;
}