#include <stdio.h>

int main()
{
    int n = 0;
    int m = 0;
    scanf("%d %d", &n, &m);
    int arr[2000] = { 0 };
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    for (int j = n; j < m + n; j++)
    {
        scanf("%d", &arr[j]);
    }
    for (int i = 0; i < (m + n) - 1; i++)
    {
        for (int j = 0; j < (m + n) - i - 1; j++)
        {
            if (arr[j] > arr[j + 1])
            {
                int temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }
    for (int i = 0; i < m + n; i++)
    {
        printf("%d ", arr[i]);
    }

        return 0;
}