#include <stdio.h>

int main() {
    int n = 0;
    int m = 0;
    scanf("%d%d", &n, &m);
    int L1[n];
    int L2[m];
    int finly[n+m];
    for (int i = 0; i < n && scanf("%d", &L1[i]); i++);
    for (int i = 0; i < m && scanf("%d", &L2[i]); i++);

    int j = 0;
    int k = 0;
    for (int i = 0; i < n + m; i++)
    {
        if (L1[j] < L2[k])
        {
            finly[i] = L1[j++];
        }
        else
        {
            finly[i] = L2[k++];
        }
        if (k == m || j == n)
        {
            if (k == m)
            {
                for (; j < n; j++)
                {
                    finly[++i] = L1[j];
                }
            }
            else 
            {
                for (; k < m; k++)
                {
                    finly[++i] = L2[k];
                }
            }
        }
         
    }

    for (int i = 0; i < n+m; i++)
    {
        printf("%d ", finly[i]);
    }
    return 0;
}