public static void main(String[] args) {
        int i, n, m, data;
        ListNode l1, l2, l3;
        ArrayList<Integer> al1 = new ArrayList<Integer>();
        ArrayList<Integer> al2 = new ArrayList<Integer>();
        Scanner cin = new Scanner(System.in);

        while (cin.hasNext()) {
            n = cin.nextInt();
            m = cin.nextInt();

            for (i = 0; i < n; i++) {
                al1.add(cin.nextInt());
            }

            for (i = 0; i < m; i++) {
                al2.add(cin.nextInt());
            }

            Iterator<Integer> itor1 = al1.iterator();
            l1 = null;
            while (itor1.hasNext()) {
                data = itor1.next();
                l1 = createList(l1, data);
            }

            Iterator<Integer> itor2 = al2.iterator();
            l2 = null;
            while (itor2.hasNext()) {
                data = itor2.next();
                l2 = createList(l2, data);
            }

            l3 = mergeTwoLists(l1, l2);
            while (l3 != null) {
                System.out.printf("%d ", l3.val);
                l3 = l3.next;
            }
            System.out.println();
        }

        cin.close();
    }