Problem: To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the second set gives the fraction denominator. However, it turned out that the programs that work with fractions in this representations aren't complete, they lack supporting the operation of reducing fractions. Implement this operation and the Empire won't forget you.

Input

The first input line contains two space-separated integers n, m (1 ≤ n, m ≤ 105) that show how many numbers the first set (the numerator) and the second set (the denominator) contain, correspondingly.

The second line contains n space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 107) — the numbers that are multiplied to produce the numerator.

The third line contains m space-separated integers: b1, b2, ..., bm (1 ≤ bi ≤ 107) — the numbers that are multiplied to produce the denominator.

Output

Print the answer to the problem in the form, similar to the form of the input data. The number of values in the sets you print nout, mout must satisfy the inequality 1 ≤ nout, mout ≤ 105, and the actual values in the sets aout, i and bout, i must satisfy the inequality 1 ≤ aout, i, bout, i ≤ 107. 

Separate the values in the lines by spaces. The printed fraction must be reduced, that is, there mustn't be such integer x (x > 1), that the numerator and the denominator of the printed fraction are divisible by x. If there are several matching answers, print any of them.

Examples

Input

3 2
100 5 2
50 10


Output

2 3
2 1
1 1 1


Input

4 3
2 5 10 20
100 1 3


Output

1 1
20
3

Note

In the first test sample the numerator equals 1000, the denominator equals 500. If we reduce fraction 1000/500 by the greatest common divisor of the numerator and the denominator (by 500), we obtain fraction 2/1.

In the second test sample the numerator equals 2000, the denominator equals 300. If we reduce fraction 2000/300 by the greatest common divisor of the numerator and the denominator (by 100), we obtain fraction 20/3.

Solution (in JAVA):

Solution:
import java.io.FileNotFoundException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.File;
import java.io.Writer;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Set;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author unnamed
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt(), m = in.nextInt();
        int[] a = IOUtils.readIntArray(in, n);
        int[] b = IOUtils.readIntArray(in, m);
        int g = Integer.MAX_VALUE;
        int MAX = Math.max(ArrayUtils.maxArray(a), ArrayUtils.maxArray(b));
        int[] erato = Eratosphene(MAX);
        Map<Integer, Long> lpB = new HashMap<Integer, Long>(), lpA = new HashMap<Integer, Long>();
        for (int i = 0; i < m; ++i) {
            int k = b[i];
            while (k != 1) {
                if (!lpB.containsKey(erato[k]))
                    lpB.put(erato[k], 1L);
                else
                    lpB.put(erato[k], lpB.get(erato[k]) + 1);
                k /= erato[k];
            }
        }
        for (int i = 0; i < n; ++i) {
            int k = a[i];
            while (k != 1) {
                if (!lpA.containsKey(erato[k]))
                    lpA.put(erato[k], 1L);
                else
                    lpA.put(erato[k], lpA.get(erato[k]) + 1);
                k /= erato[k];
            }
        }
        Map<Integer, Long> toDel = new HashMap<Integer, Long>();
        for (int h : lpA.keySet())
            if (lpB.containsKey(h))
                toDel.put(h, Math.min(lpA.get(h), lpB.get(h)));
        int cnt = 0;
        Map<Integer, Long> toDel2 = new HashMap<Integer, Long>(toDel);
        while (cnt < n & toDel.size() > 0) {
            int h = a[cnt];
            while (h > 1) {
                int del = erato[h];
                if (toDel.containsKey(del)) {
                    toDel.put(del, toDel.get(del) - 1);
                    if (toDel.get(del) == 0)
                        toDel.remove(del);
                    a[cnt] /= del;
                }
                h /= del;
            }
            ++cnt;
        }
        cnt = 0;
        while (cnt < m & toDel2.size() > 0) {
            int h = b[cnt];
            while (h > 1) {
                int del = erato[h];
                if (toDel2.containsKey(del)) {
                    toDel2.put(del, toDel2.get(del) - 1);
                    if (toDel2.get(del) == 0)
                        toDel2.remove(del);
                    b[cnt] /= del;
                }
                h /= del;
            }
            ++cnt;
        }
        List<Integer> ansA = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i)
            if (a[i] > 1)
                ansA.add(a[i]);
        List<Integer> ansB = new ArrayList<Integer>();
        for (int i = 0; i < m; ++i)
            if (b[i] > 1)
                ansB.add(b[i]);
        if (ansA.size() == 0)
            ansA.add(1);
        if (ansB.size() == 0)
            ansB.add(1);
        out.println(ansA.size(), ansB.size());
        for (int i : ansA) out.print(i + " ");
        out.println();
        for (int i : ansB) out.print(i + " ");
    }

    public int[] Eratosphene(int N) {
        int[] lp = new int[N + 1];
        List<Integer> pr = new ArrayList<Integer>();
        for (int i = 2; i <= N; ++i) {
            if (lp[i] == 0) {
                lp[i] = i;
                pr.add(i);
            }
            for (int j = 0; j < (int) pr.size() && pr.get(j) <= lp[i] && i * pr.get(j) <= N; ++j)
                lp[i * pr.get(j)] = pr.get(j);
        }
        return lp;
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader(File f) {
        try {
            br = new BufferedReader(new FileReader(f));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public InputReader(InputStream f) {
        br = new BufferedReader(new InputStreamReader(f));
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void println(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }
}

class IOUtils {

    public static int[] readIntArray(InputReader in, int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++)
            array[i] = in.nextInt();
        return array;
    }

    }

class ArrayUtils {

    public static int maxArray(int... array) {
        int ans = array[0];
        for (int i = 1; i < array.length; ++i)
            if (array[i] > ans) ans = array[i];
        return ans;
    }

    }