#include <iostream>
using namespace std;
int a[10005],b[10005];
void paixv(int a[],int b[],int n,int m){
int tmp[20005];
int i = 1,j = 1;
while (i <= n && j <= m){
if (a[i] <= b[j]){
cout << a[i] << " ";
i++;
}else{
cout << b[j] << " ";
j++;
}
}
while (i <= n){
cout << a[i] << " ";
i++;
}
while (j <= m){
cout << b[j] << " ";
j++;
}
return;
}
int main(){
int n,m;
cin >> n >> m;
for (int i = 1; i <= n;i++){
cin >> a[i];
}
for (int i = 1; i <= m;i++){
cin >> b[i];
}
paixv(a,b,n,m);
return 0;
}