#include <stdio.h>

int main() {
    int n1, n2,m;
    scanf("%d", &n1);

    int arr1[n1];
    int i;
    for (i = 0; i < n1; i++) {
        scanf("%d", &arr1[i]);
    }

    scanf("%d", &n2);

    int arr2[n2];
    for (i = 0; i < n2; i++) {
        scanf("%d", &arr2[i]);
    }

    int merged[n1 + n2];
	int j = 0;
	int k = 0;

    while (i < n1 && j < n2) {
        if (arr1[i] < arr2[j]) {
            merged[k++] = arr1[i++];
        } else {
            merged[k++] = arr2[j++];
        }
    }

    while (i < n1) {
        merged[k++] = arr1[i++];
    }

    while (j < n2) {
        merged[k++] = arr2[j++];
    }

    for (m = 0; m < n1 + n2; m++) {
        printf("%d", merged[m]);
        if (m < n1 + n2 - 1) {
            printf(" ");
        }
    }

    return 0;
}
