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 javax.jws.Oneway;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;

import java.security.PublicKey;
import java.util.*;

public class Solution{


    class C
    {
        int n;
        int[]nums;
        int[]pows;
        int[][]r;
        int[][]p;
        public C(int n)throws Exception
        {
            this.n=n;
            nums=new int[n];
            pows=new int[len];
            r=new int[n][];
            p=new int[n][];
            for(int i=0;i<n;i++)
            {
                doIt(i);
            }

        }
        void doIt(int at)throws Exception
        {
            nums[at]=nextInt();
            int t=nums[at];
            ArrayList<Integer>l1=new ArrayList<Integer>();
            ArrayList<Integer>p1=new ArrayList<Integer>();

            while (t>1)
            {

                int x=d[t];
                int cnt=0;

                while (t%x==0)
                {

                    cnt++;
                    t/=x;
                }
                l1.add(inds[x]);
                p1.add(cnt);
            }
            r[at]=new int[l1.size()];
            p[at]=new int[p1.size()];
            for(int i=0;i<r[at].length;i++)
            {
                r[at][i]=l1.get(i);
                p[at][i]=p1.get(i);
                pows[r[at][i]]+=p[at][i];
            }

        }
        void makeGood(int[]rem)
        {
            for(int at=0;at<n;at++)
            {
                for(int i=0;i<r[at].length;i++)
                {
                    int z=Math.min(rem[r[at][i]],p[at][i]);
                    p[at][i]-=z;
                    rem[r[at][i]]-=z;
                }
            }
        }
        void print()
        {
            for(int at=0;at<n;at++)
            {
                int cur=1;
                for(int i=0;i<r[at].length;i++)
                {
                    for(int j=0;j<p[at][i];j++)
                        cur*=what[r[at][i]];
                }
                if(at==n-1)
                    writer.println(cur);
                else
                    writer.print(cur+" ");
            }

        }
    }



    int[]d;
    int maxn=10000001;
    int[]inds;
    int len;
    int[]what;
    void solve()throws Exception
    {

        d=new int[maxn];
        for(int i=2;i<d.length;i++)
            d[i]=i;
        for(int i=2;i*i<d.length;i++)
            if(d[i]==i)
                for(int j=i*i;j<d.length;j+=i)
                    d[j]=i;
        inds=new int[maxn];
        Arrays.fill(inds,-1);
        len=0;
        for(int i=2;i<d.length;i++)
            if(d[i]==i)
                inds[i]=len++;
        what=new int[len];
        len=0;
        for(int i=2;i<d.length;i++)
            if(d[i]==i)
                what[len++]=i;
        int n=nextInt();
        int m=nextInt();
        C c1=new C(n);
        C c2=new C(m);
        int[]rem=new int[len];
        for(int i=0;i<rem.length;i++)
            rem[i]=Math.min(c1.pows[i],c2.pows[i]);
        int[]temp=rem.clone();
        c1.makeGood(rem);
        rem=temp;
        c2.makeGood(rem);
        writer.println(n+" "+m);
        c1.print();
        c2.print();



    }

    ////////////
    BufferedReader reader;
    PrintWriter writer;
    StringTokenizer stk;
    void run()throws Exception
    {

        reader=new BufferedReader(new InputStreamReader(System.in));
        //reader=new BufferedReader(new FileReader("3.in"));
        stk=null;
        writer=new PrintWriter(new PrintWriter(System.out));
        //writer=new PrintWriter(new FileWriter("output.txt"));
        solve();
        reader.close();
        writer.close();
    }
    int nextInt()throws Exception
    {
        return Integer.parseInt(nextToken());
    }

    long nextLong()throws Exception
    {
        return Long.parseLong(nextToken());

    }
    double nextDouble()throws Exception
    {
        return Double.parseDouble(nextToken());


    }

    String nextString()throws Exception
    {
        return nextToken();
    }
    String nextLine()throws Exception
    {
        return reader.readLine();
    }
    String nextToken()throws Exception
    {
        if(stk==null || !stk.hasMoreTokens())
        {
            stk=new StringTokenizer(nextLine());
            return nextToken();

        }
        return stk.nextToken();
    }

    public static void main(String[]args) throws Exception
    {
        new Solution().run();
    }








}