#include <stdio.h>

// Function to merge two sorted arrays into one sorted array
void mergeSortedArrays(int arr1[], int size1, int arr2[], int size2) {
    int merged[size1 + size2]; // Result array to store merged sorted elements
    int i = 0, j = 0, k = 0;   // i for arr1, j for arr2, k for merged array

    // Merge the arrays while both arrays have elements
    while (i < size1 && j < size2) {
        if (arr1[i] <= arr2[j]) {
            merged[k++] = arr1[i++];
        } else {
            merged[k++] = arr2[j++];
        }
    }

    // If there are remaining elements in arr1, add them to merged array
    while (i < size1) {
        merged[k++] = arr1[i++];
    }

    // If there are remaining elements in arr2, add them to merged array
    while (j < size2) {
        merged[k++] = arr2[j++];
    }

    // Print the merged sorted array
    int m;
    for (m = 0; m < size1 + size2; m++) {
        if (m > 0) {
            printf(" ");
        }
        printf("%d", merged[m]);
    }
    printf("\n");
}

int main() {
    int size1, size2;

    // Input the first sorted array
    scanf("%d", &size1);
    int arr1[size1], i;
    for (i = 0; i < size1; i++) {
        scanf("%d", &arr1[i]);
    }

    // Input the second sorted array
    scanf("%d", &size2);
    int arr2[size2];
    for (i = 0; i < size2; i++) {
        scanf("%d", &arr2[i]);
    }

    // Merge and print the sorted arrays
    mergeSortedArrays(arr1, size1, arr2, size2);

    return 0;
}
