import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int[] aarr = new int[a];
        int[] barr = new int[b];
        for(int i = 0; i < aarr.length; i++) {
            aarr[i] = scan.nextInt();
        }
        for(int i = 0; i < barr.length; i++) {
            barr[i] = scan.nextInt();
        }
        //可以用数组存放aarr和barr这两个数组,再正序输出
        int[] parr = new int[a + b];
        System.arraycopy(aarr, 0, parr, 0, a);
        System.arraycopy(barr, 0, parr, a, b);
        //关于arraycopy的用法可以参照
        //https://blog.csdn.net/Lilip_/article/details/124280524?spm=1001.2014.3001.5501
        
        Arrays.sort(parr);
        for(int i = 0; i < parr.length; i++) {
            System.out.print(parr[i] + " ");
        }
        
    }
}