#include <stdio.h>
int main()
{
    int a = 0;
    int b = 0;
    int arr[2000] = { 0 };
    scanf("%d%d", &a, &b);
    getchar();//拿走回车符
    int i = 0;
    for (i = 0; i < a; i++)
    {
        scanf("%d", &arr[i]);
        getchar();//最后一次循环后,按下回车,拿走回车符
    }
    for (i = a; i < b + a; i++)
    {
        scanf("%d", &arr[i]);
    }
    int flag = 1;//判断是否已经是有序的升序
    for (i = 0; i < a + b - 1; i++)//冒泡排序
    {
        int j = 0;
        for (j = 0; j < a + b - 1 - i; j++)
        {
            if (arr[j] > arr[j + 1])
            {
                int temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
                flag = 0;
            }
        }
        if (flag == 1)
            break;
    }
    for (i = 0; i < a + b; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}