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.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn Agrawal coderbond007  PLEASE!! PLEASE!! HACK MY SOLUTION!!
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = in.nextIntArray(n);
            int[] b = in.nextIntArray(m);
            int[] lpf = NT.enumLowestPrimeFactors(10000000);
            int[] count = new int[10000001];
            for (int i = 0; i < n; ++i) {
                int temp = a[i];
                while (temp != 1) {
                    int p = lpf[temp];
                    while (temp % p == 0) {
                        temp /= p;
                        count[p]++;
                    }
                }
            }
            for (int i = 0; i < m; ++i) {
                int temp = b[i];
                while (temp != 1) {
                    int p = lpf[temp];
                    while (temp % p == 0) {
                        temp /= p;
                        count[p]--;
                    }
                }
            }
            out.println(n + " " + m);
            for (int i = 0; i < n; ++i) {
                if (i != 0) out.print(" ");
                int x = a[i];
                int y = a[i];
                while (x > 1) {
                    if (count[lpf[x]] > 0) count[lpf[x]]--;
                    else y /= lpf[x];
                    x /= lpf[x];
                }
                out.print(y);
            }
            out.println();
            for (int i = 0; i < m; ++i) {
                if (i != 0) out.print(" ");
                int x = b[i];
                int y = b[i];
                while (x > 1) {
                    if (count[lpf[x]] < 0) count[lpf[x]]++;
                    else y /= lpf[x];
                    x /= lpf[x];
                }
                out.print(y);
            }
            out.println();
        }

    }

    static class NT {
        public static int[] enumLowestPrimeFactors(int n) {
            int tot = 0;
            int[] lpf = new int[n + 1];
            int u = n + 32;
            double lu = Math.log(u);
            int[] primes = new int[(int) (u / lu + u / lu / lu * 1.5)];
            for (int i = 2; i <= n; i++)
                lpf[i] = i;
            for (int p = 2; p <= n; p++) {
                if (lpf[p] == p)
                    primes[tot++] = p;
                int tmp;
                for (int i = 0; i < tot && primes[i] <= lpf[p] && (tmp = primes[i] * p) <= n; i++) {
                    lpf[tmp] = primes[i];
                }
            }
            return lpf;
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        private static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}