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.util.*;
import java.io.*;

public class C
{
   public static void main(String[] args)
   {
      new C(new FastScanner());
   }

	int[] primes;
	void genPrimes(int mx) {
		boolean[] isPrime = new boolean[mx+1];
		Arrays.fill(isPrime,true);
		int numPrimes = 0;
      isPrime[0] = isPrime[1] = false;
		for(int i=0; i<=mx; i++)
			if(isPrime[i]) {
            numPrimes++;
				if(i*1L*i <= mx)	for(int j=i*i; j<=mx; j+=i)
					isPrime[j] = false;
			}
      int ptr = 0;
      primes = new int[numPrimes];
		for(int i=0; i<=mx; i++)
			if(isPrime[i])
            primes[ptr++] = i;
   }
	
   ArrayList<Factor> getFactors(int val)
   {
      ArrayList<Factor> res = new ArrayList<Factor>(80);
      for (int p : primes)
      {
         if (p*1L*p > val)
            break;
         if ((val%p) == 0)
         {
            int cnt = 0;
            while ((val%p) == 0)
            {
               val = val/p;
               cnt++;
            }
            res.add(new Factor(p, cnt));
         }
      }

      if (val != 1)
         res.add(new Factor(val, 1));
      return res;
   }


   // Return the factors of the value in regular form
   int[] getFactors(int N, FastScanner in, ArrayList<ArrayList<Factor>> factors)
   {
      int[] cnt = new int[primes.length];
      for (int i=0; i<N; i++)
      {
         int v = in.nextInt();
         ArrayList<Factor> ff = getFactors(v);
         //System.out.println(v+" "+ff);
         for (Factor f : ff)
            cnt[Arrays.binarySearch(primes, f.val)] += f.cnt;
         factors.add(ff);
      }
      return cnt;
   }


   public C(FastScanner in)
   {
      genPrimes(10000000);
      
      int N1 = in.nextInt();
      int N2 = in.nextInt();

      ArrayList<ArrayList<Factor>> group1 = new ArrayList<ArrayList<Factor>>();
      ArrayList<ArrayList<Factor>> group2 = new ArrayList<ArrayList<Factor>>();

      int[] a = getFactors(N1, in, group1);
      int[] b = getFactors(N2, in, group2);
      for (int i=0; i<primes.length; i++)
         b[i] = a[i] = Math.min(a[i],b[i]);
     
      int ptr = 0;
      int[] res1 = new int[N1];
      int[] res2 = new int[N2];
      for (ArrayList<Factor> g : group1)
      {
         int val = 1;
         for (Factor f : g)
         {
            int id = Arrays.binarySearch(primes, f.val);
            int v = Math.min(f.cnt, a[id]);
            f.cnt -= v;
            a[id] -= v;
            while (f.cnt-->0)
               val *= f.val;
         }
         res1[ptr++] = val;
      }

      ptr = 0;
      for (ArrayList<Factor> g : group2)
      {
         int val = 1;
         for (Factor f : g)
         {
            int id = Arrays.binarySearch(primes, f.val);
            int v = Math.min(f.cnt, b[id]);
            f.cnt -= v;
            b[id] -= v;
            while (f.cnt-->0)
               val *= f.val;
         }
         res2[ptr++] = val;
      }

      PrintWriter out = new PrintWriter(System.out);
      out.printf("%d %d%n", N1, N2);
      StringBuilder sb = new StringBuilder();
      for (int v : res1)
      {
         sb.append(v);
         sb.append(' ');
      }
      out.println(sb.toString().trim());
      sb = new StringBuilder();
      for (int v : res2)
      {
         sb.append(v);
         sb.append(' ');
      }
      out.println(sb.toString().trim());
      out.close();
   }
}

class Factor
{
   int val, cnt;
   public Factor(int vv, int cc)
   {
      val = vv; cnt = cc;
   }

   public String toString()
   {
      return String.format("(%d,%d)", val, cnt);
   }
}

class FastScanner{
   private InputStream stream;
   private byte[] buf = new byte[1024];
   private int curChar;
   private int numChars;

   public FastScanner()
   {
      stream = System.in;
   }

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

   boolean isSpaceChar(int c)
   {
      return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
   }
   
   boolean isEndline(int c)
   {
      return c=='\n'||c=='\r'||c==-1;
   }

   int nextInt()
   {
      return Integer.parseInt(next());
   }
   
   long nextLong()
   {
      return Long.parseLong(next());
   }

   double nextDouble()
   {
      return Double.parseDouble(next());
   }

   String next(){
      int c = read();
      while (isSpaceChar(c))
         c = read();
      StringBuilder res = new StringBuilder();
      do{
         res.appendCodePoint(c);
         c = read();
      }while(!isSpaceChar(c));
      return res.toString();
   }
   
   String nextLine(){
      int c = read();
      while (isEndline(c))
         c = read();
      StringBuilder res = new StringBuilder();
      do{
         res.appendCodePoint(c);
         c = read();
      }while(!isEndline(c));
      return res.toString();
   }
}