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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Collections;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CReducingFractions solver = new CReducingFractions();
        solver.solve(1, in, out);
        out.close();
    }

    static class CReducingFractions {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int m = in.scanInt();
            int[] SPF = CodeX.SPF(10000000 + 10);
            int a[] = new int[n];
            int b[] = new int[m];
            in.scanInt(a);
            in.scanInt(b);


            int hashA[] = new int[10000000 + 10];
            int hashB[] = new int[10000000 + 10];

            for (int k : a) {
                int x = k;
                while (x != 1) {
                    hashA[SPF[x]]++;
                    x /= SPF[x];
                }
            }

            for (int k : b) {
                int x = k;
                while (x != 1) {
                    hashB[SPF[x]]++;
                    x /= SPF[x];
                }
            }


            for (int i = 0; i < 10000000 + 10; i++) {
                int min = Math.min(hashA[i], hashB[i]);
                hashA[i] -= min;
                hashB[i] -= min;
            }


            out.println(n + " " + m);
            for (int k : a) {
                int x = k;
                long ans = 1;
                while (x != 1) {
                    if (hashA[SPF[x]] > 0) {
                        hashA[SPF[x]]--;
                        ans *= SPF[x];
                    }
                    x /= SPF[x];
                }

                out.print(ans + " ");
            }


            out.println();

            for (int k : b) {
                int x = k;
                long ans = 1;
                while (x != 1) {
                    if (hashB[SPF[x]] > 0) {
                        hashB[SPF[x]]--;
                        ans *= SPF[x];
                    }
                    x /= SPF[x];
                }

                out.print(ans + " ");
            }
        }

        class pair {
            long a;
            long b;

            public pair(long a, long b) {
                this.a = a;
                this.b = b;
            }

        }

    }

    static class CodeX {
        public static long power(long x, long y) {
            long res = 1;
            while (y > 0) {
                if ((y & 1) != 0)
                    res = (res * x);
                y = y >> 1;
                x = (x * x);
            }
            return res;
        }

        public static int[] SPF(int MAXN) {
            int[] spf = new int[MAXN + 5];
            spf[1] = 1;
            for (int i = 2; i < MAXN; i++) spf[i] = i;
            for (int i = 4; i < MAXN; i += 2) spf[i] = 2;
            for (int i = 3; i * i < MAXN; i++) {
                if (spf[i] == i) {
                    for (int j = i * i; j < MAXN; j += i)
                        if (spf[j] == j)
                            spf[j] = i;
                }
            }
            return spf;
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public void scanInt(int[] A) {
            for (int i = 0; i < A.length; i++) A[i] = scanInt();
        }

    }
}