import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> result = new ArrayList<>();
        // 读取 n 和 m
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        // 读取第一个序列
        int[] arr1 = new int[n];
        for (int i = 0; i < n; i++) {
            arr1[i] = sc.nextInt();
            result.add(arr1[i]);
        }
        
        // 读取第二个序列
        int[] arr2 = new int[m];
        for (int i = 0; i < m; i++) {
            arr2[i] = sc.nextInt();
            result.add(arr2[i]);
        }
        
    
        
        
        Collections.sort(result);
        for (int i = 0; i < result.size(); i++) {
            System.out.print(result.get(i) + " ");
        }
    }
}