int main() {
    int n, m, temp;
    scanf("%d %d", &n, &m);
    int x[n + m];
    for (int i = 0; i < n; i++) scanf("%d ", &x[i]);
    for (int j = 0; j < m; j++) scanf("%d ", &x[j + n]);  //合并一二行
    for (int k = 0; k < m + n; k++) {  //从小到大排序
        for (int z = 0; z < m + n; z++) {
            if (x[k] < x[z]) {
                temp = x[k];
                x[k] = x[z];
                x[z] = temp;
            }
        }
    }
    for (int val = 0; val < m + n; val++) printf("%d ", x[val]);
    return 0;
}