//BC100 有序序列合并
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int n, m, i, j, k = 0;
	scanf("%d %d", &n, &m);
	int* arr_n = (int*)malloc(sizeof(int)*n); 
	int* arr_m = (int*)malloc(sizeof(int)*m); 
	int* ret = (int*)malloc(sizeof(int)*(m+n));
	for (i = 0; i < n; i++) {
		scanf("%d", &arr_n[i]);
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &arr_m[i]);
	}
	i = 0, j = 0;
	while(1){
		ret[k++] = (arr_n[i] < arr_m[j]) ? arr_n[i++] : arr_m[j++];
		if (i == n) {
			while (j < m) {
				ret[k++] = arr_m[j++];
			}
			break;
		}
		else if (j == m) {
			while (i < n) {
				ret[k++] = arr_n[i++];
			}
			break;
		}
	}
	for (i = 0; i < n + m; i++) {
		printf("%d ", ret[i]); 
	}
	return 0 ;
}