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.*;
import java.lang.reflect.Array;
import java.math.*;
import java.security.*;
import java.util.*;

public class Main {
    private static int [] [] cnt;
    private static int [] prime;
    private static int MAX = 10*1000*1000;
    private static int [] [] to_lose;

    private static void sieve(){
        prime = new int[MAX+1];
        for (int i = 2; i <= MAX; i++)
            if (prime[i] == 0) {
                prime[i] = i;
                for (long j = i*(long)i; j <= MAX; j += i)
                    prime[(int)j] = i;
            }
    }


    public static void main(String[] args) throws NumberFormatException, IOException {
        IO io;
        try {
            io = new IO("in.in", null);
        }
        catch (Exception e) {
            io = new IO(null, null);
        }
        sieve();
        cnt = new int[2][MAX+1];
        int n = io.getNextInt();
        int m = io.getNextInt();
        int [] [] A = new int[2][];
        A[0] = new int[n];
        A[1] = new int[m];
        for (int j = 0; j < 2; j++)
            for (int i = 0; i < A[j].length; i++) {
                int x = A[j][i] = io.getNextInt();
                while (x > 1) {
                    int p = prime[x];
                    while (x%p == 0) {
                        x /= p;
                        cnt[j][p]++;
                    }
                }
            }

        to_lose = new int[2][MAX+1];
        for (int i = 2; i <= MAX; i++) {
            int g = Math.min(cnt[0][i], cnt[1][i]);
            to_lose[0][i] = to_lose[1][i] = g;
//            if (g > 0) System.err.println("lose " + i + " " + g);
        }
        io.println(n + " " + m);
        for (int j = 0; j < 2; j++) {
            for (int i = 0; i < A[j].length; i++) {
                int x = A[j][i];
                A[j][i] = 1;
                while (x > 1) {
                    int p = prime[x], e = 0;
                    while (x % p == 0) {
                        e++;
                        x /= p;
                    }
                    int d = Math.min(e, to_lose[j][p]);
                    to_lose[j][p] -= d;
                    e -= d;
                    while (e > 0) {
                        e--;
                        A[j][i] *= p;
                    }
                }
                io.print(A[j][i] + " ");
            }
            io.println("");
        }

        io.close();
    }

    private static long gcd(long a, long b) {
        while (b > 0) {
            long t = a%b;
            a = b;
            b = t;
        }
        return a;
    }
}



class pollardRho{
    private static BigInteger zero = new BigInteger("0");
    private static BigInteger one  = new BigInteger("1");
    private static BigInteger two  = new BigInteger("2");
    private static SecureRandom r = new SecureRandom();
    private static Queue<BigInteger> tasks = new LinkedList<>();
    private static ArrayList<BigInteger> primes = new ArrayList<>();

    public static long getBiggestPrime(long n) {
        long N = n;
        tasks.clear();
        primes.clear();
        tasks.add(BigInteger.valueOf(n));
        while (!tasks.isEmpty()){
            BigInteger x = tasks.poll();
            BigInteger P = one;
            for (BigInteger p : primes)
                if (P.compareTo(p) < 0)
                    P = p;
            for (BigInteger p : primes){
                while (x.remainder(p).equals(zero))
                    x = x.divide(p);
            }
//            System.err.println(x + " " + P);
            if(x.compareTo(P) <= 0) continue;
            factor(x);
        }
        BigInteger P = one;
        for (BigInteger p : primes)
            if (P.compareTo(p) < 0)
                P = p;
//        System.out.println(N + " " + tasks + " " + primes);
        return P.longValue();
    }

    private static void factor(BigInteger N) {
        if (N.compareTo(one) == 0) return;
        if (N.isProbablePrime(20)) {
            primes.add(N);
            return;
        }
        BigInteger d = rho(N);

        if (d.compareTo(one) != 0)
            tasks.add(d);
        N = N.divide(d);
        if (N.compareTo(one) != 0)
            tasks.add(N);
    }

    private static BigInteger rho(BigInteger N) {
        BigInteger d;
        BigInteger c  = new BigInteger(N.bitLength(), r);
        BigInteger p  = new BigInteger(N.bitLength(), r);
        BigInteger q = p;

        if (N.mod(two).compareTo(zero) == 0) return two;

        d = one;
        while(d.compareTo(one) == 0) {
            p  =  p.multiply(p).mod(N).add(c).mod(N);
            q = q.multiply(q).mod(N).add(c).mod(N);
            q = q.multiply(q).mod(N).add(c).mod(N);
            d = p.subtract(q).gcd(N);
        }
        return d;
    }
}
class IO{
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter writer;
    private String inputFile,outputFile;

    public boolean hasMore() throws IOException{
        if(st != null && st.hasMoreTokens()) return true;
        if(br != null && br.ready()) return true;
        return false;
    }

    public String getNext() throws FileNotFoundException, IOException{
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String getNextLine() throws FileNotFoundException, IOException{
        return br.readLine().trim();
    }

    public int getNextInt() throws FileNotFoundException, IOException{
        return Integer.parseInt(getNext());
    }
    public long getNextLong() throws FileNotFoundException, IOException{
        return Long.parseLong(getNext());
    }

    public void print(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f" ,x);
    }
    public void println(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f\n" ,x);
    }
    public void print(Object o) throws  IOException{
        writer.print(o.toString());
    }

    public void println(Object o) throws  IOException{
        writer.println(o.toString());
    }
    public IO(String x,String y) throws FileNotFoundException, IOException{
        inputFile = x;
        outputFile = y;
        if(x != null) br = new BufferedReader(new FileReader(inputFile));
        else br = new BufferedReader(new InputStreamReader(System.in));
        if(y != null) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        else writer = new PrintWriter(new OutputStreamWriter(System.out));
    }

    protected void close() throws IOException{
        br.close();
        writer.close();
    }
    public void outputArr(Object [] A) throws IOException{
        int L = A.length;
        for (int i = 0;i < L;i++) {
            if(i > 0) writer.print(" ");
            writer.print(A[i]);
        }
        writer.print("\n");
    }
}