#include <iostream>
using namespace std;
int main() {
int n, m, v[100001], w[100001];
cin >> n;
for (int i = 1; i <= n; ++i) { // Citim sirul v
cin >> v[i];
}
cin >> m;
for (int i = 1; i <= m; ++i) { // Citim sirul w
cin >> w[i];
}
int aux[n + m]; //noul sir format
int k = 0; //cu ajutorul acestei variabile vom pune elementele in noul sir format
int i = 1, j = 1;
//vom parcurge simultan cele doua siruri si vom compara elementele
while (i <= n && j <= m) {
if (v[i] < w[j]) //punem cel mai mic element dintre cele doua
{
k++;
aux[k] = v[i];
i++;
} else {
k++;
aux[k] = w[j];
j++;
}
}
// exista posibilitate sa terminam elementele dintr-un sir, iar din altul nu
while (i <= n) {
k++;
aux[k] = v[i];
i++;
}
while (j <= m) {
k++;
aux[k] = w[j];
j++;
}
// afisam noul sir
for (i = 1; i <= k; i++) {
cout << aux[i] << ' ';
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbiwgbSwgdlsxMDAwMDFdLCB3WzEwMDAwMV07CiAgICBjaW4gPj4gbjsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgeyAvLyBDaXRpbSBzaXJ1bCB2CiAgICAgICAgY2luID4+IHZbaV07CiAgICB9CiAgICBjaW4gPj4gbTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG07ICsraSkgeyAvLyBDaXRpbSBzaXJ1bCB3CiAgICAgICAgY2luID4+IHdbaV07CiAgICB9CiAgICBpbnQgYXV4W24gKyBtXTsgLy9ub3VsIHNpciBmb3JtYXQKICAgIGludCBrID0gMDsgLy9jdSBhanV0b3J1bCBhY2VzdGVpIHZhcmlhYmlsZSB2b20gcHVuZSBlbGVtZW50ZWxlIGluIG5vdWwgc2lyIGZvcm1hdAogICAgaW50IGkgPSAxLCBqID0gMTsKICAgIC8vdm9tIHBhcmN1cmdlIHNpbXVsdGFuIGNlbGUgZG91YSBzaXJ1cmkgc2kgdm9tIGNvbXBhcmEgZWxlbWVudGVsZQogICAgd2hpbGUgKGkgPD0gbiAmJiBqIDw9IG0pIHsKICAgICAgICBpZiAodltpXSA8IHdbal0pIC8vcHVuZW0gY2VsIG1haSBtaWMgZWxlbWVudCBkaW50cmUgY2VsZSBkb3VhCiAgICAgICAgewogICAgICAgICAgICBrKys7CiAgICAgICAgICAgIGF1eFtrXSA9IHZbaV07CiAgICAgICAgICAgIGkrKzsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBrKys7CiAgICAgICAgICAgIGF1eFtrXSA9IHdbal07CiAgICAgICAgICAgIGorKzsKICAgICAgICB9CiAgICB9CiAgICAvLyBleGlzdGEgcG9zaWJpbGl0YXRlIHNhIHRlcm1pbmFtIGVsZW1lbnRlbGUgZGludHItdW4gc2lyLCBpYXIgZGluIGFsdHVsIG51CiAgICB3aGlsZSAoaSA8PSBuKSB7CiAgICAgICAgaysrOwogICAgICAgIGF1eFtrXSA9IHZbaV07CiAgICAgICAgaSsrOwogICAgfQoKICAgIHdoaWxlIChqIDw9IG0pIHsKICAgICAgICBrKys7CiAgICAgICAgYXV4W2tdID0gd1tqXTsKICAgICAgICBqKys7CiAgICB9CiAgICAvLyBhZmlzYW0gbm91bCBzaXIKICAgIGZvciAoaSA9IDE7IGkgPD0gazsgaSsrKSB7CiAgICAgICAgY291dCA8PCBhdXhbaV0gPDwgJyAnOwogICAgfQogICAgcmV0dXJuIDA7Cn0=