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.util.ArrayList;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

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

class TaskC {
    private final int oo = (int) 1e7;

    private int n, m;
    private int[] prime, numerator, denominator, a, b;
    private ArrayList<Integer> Numerator, Denominator;
    private StringBuffer res = new StringBuffer();

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        n = in.nextInt();
        m = in.nextInt();

        a = new int[n + 1];
        b = new int[m + 1];
        prime = new int[oo + 5];
        numerator = new int[oo + 5];
        denominator = new int[oo + 5];

        for (int i = 2; i <= oo; ++i)
            if (prime[i] == 0) {
                long j = (long) i * i;
                while (j <= oo) {
                    prime[((int) j)] = i;
                    j += i;
                }
            }

        for (int i = 1; i <= n; ++i) {
            int x = in.nextInt();
            a[i] = x;
            while (prime[x] > 0) {
                numerator[prime[x]]++;
                x /= prime[x];
            }
            ++numerator[x];
        }

        for (int i = 1; i <= m; ++i) {
            int x = in.nextInt();
            b[i] = x;
            while (prime[x] > 0) {
                denominator[prime[x]]++;
                x /= prime[x];
            }
            ++denominator[x];
        }

        for(int i = 2; i <= oo; ++i) {
            int value = Math.min(numerator[i], denominator[i]);
            numerator[i] -= value;
            denominator[i] -= value;
        }

        Numerator = new ArrayList<>();
        Denominator = new ArrayList<>();

        for(int i = 1; i <= n; ++i) {
            int value = 1;
            while (prime[a[i]] > 0) {
                if (numerator[prime[a[i]]]-- > 0) value *= prime[a[i]];
                a[i] /= prime[a[i]];
            }
            if (numerator[a[i]]-- > 0) value *= a[i];
            Numerator.add(value);
        }

        for(int i = 1; i <= m; ++i) {
            int value = 1;
            while (prime[b[i]] > 0) {
                if (denominator[prime[b[i]]]-- > 0) value *= prime[b[i]];
                b[i] /= prime[b[i]];
            }
            if (denominator[b[i]]-- > 0) value *= b[i];
            Denominator.add(value);
        }

        res.append(Numerator.size()).append(" ").append(Denominator.size()).append("\n");
        for(int i : Numerator) res.append(i).append(" ");
        res.append("\n");
        for(int i : Denominator) res.append(i).append(" ");

        out.println(res);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        } catch (Exception e) {
            throw new UnknownError(e.getMessage());
        }
    }

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

}