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[] leastPrimeDivisors = MathUtils.LinearEratosphene(MAX);
        Map<Integer, Integer> primeFactorsB = findAllPrimeFactors(b, leastPrimeDivisors);
        Map<Integer, Integer> primeFactorsA = findAllPrimeFactors(a, leastPrimeDivisors);
        Map<Integer, Integer> primeFactorsGCD = new HashMap<Integer, Integer>();
        for (int h : primeFactorsA.keySet())
            if (primeFactorsB.containsKey(h))
                primeFactorsGCD.put(h, Math.min(primeFactorsA.get(h), primeFactorsB.get(h)));
        simplify(a, primeFactorsGCD, leastPrimeDivisors);
        simplify(b, primeFactorsGCD, leastPrimeDivisors);
        List<Integer> ansA = removeOnes(n, a);
        List<Integer> ansB = removeOnes(m, b);
        out.println(ansA.size(), ansB.size());
        for (int i : ansA) out.print(i + " ");
        out.println();
        for (int i : ansB) out.print(i + " ");
    }

    private List<Integer> removeOnes(int n, int[] a) {
        List<Integer> ansA = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i)
            if (a[i] > 1)
                ansA.add(a[i]);
        if (ansA.size() == 0)
            ansA.add(1);
        return ansA;
    }

    public Map<Integer, Integer> findAllPrimeFactors(int[] array, int[] sieve) {
        Map<Integer, Integer> ans = new HashMap<Integer, Integer>();
        for (int elem : array) {
            int k = elem;
            while (k != 1) {
                if (!ans.containsKey(sieve[k]))
                    ans.put(sieve[k], 1);
                else
                    ans.put(sieve[k], ans.get(sieve[k]) + 1);
                k /= sieve[k];
            }
        }
        return ans;
    }

    public void simplify(int[] array, Map<Integer, Integer> primeFactors, int[] sieve) {
        int cnt = 0;
        Map<Integer, Integer> toDel = new HashMap<Integer, Integer>(primeFactors);
        while (cnt < array.length & toDel.size() > 0) {
            int h = array[cnt];
            while (h > 1) {
                int del = sieve[h];
                if (toDel.containsKey(del)) {
                    toDel.put(del, toDel.get(del) - 1);
                    if (toDel.get(del) == 0)
                        toDel.remove(del);
                    array[cnt] /= del;
                }
                h /= del;
            }
            ++cnt;
        }
    }
}

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;
    }

    }

class MathUtils {


    public static int[] LinearEratosphene(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;
    }

    }