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

public class Main
{	
	public BufferedReader in;
	public PrintStream out;
	
	public boolean log_enabled = true;
	
	static int[] primes;
	static int p_count;

	public static void get_primes(int n)
	{
		primes = new int[1000000];
		
		boolean[] v = new boolean[n+1];
		int i,j;
		for (i=2; i<=n;i++)
		{
			v[i] = true;
		}
		
		for (i=2; i*i<=n;i++)
		{
			if (v[i])
			{
				for (j=i; i*j<=n; j++)
				{
					v[i*j]=false;
				}
			}
		}
		
		p_count = 0;
		for (i=2; i<=n; i++)
		{
			if (v[i])
			{
				primes[p_count++] = i;
			}
		}
	}
	
	public static int p_number(int x, int l, int r)
	{
		if (l>r)
		{
			return -1;
		}
	
		int c = (l+r) >> 1;
		
		if (primes[c]<x)
		{
			return p_number(x, c+1, r);
		}
		
		if (primes[c]>x)
		{
			return p_number(x, l, c-1);
		}
		
		return c;
	}
	
	public static int sqrt(int n)
	{
		return (int)Math.sqrt(n);
	}
	
	public int factors(int n, int[] f, int[] p)
	{
		int x = p_number(n, 1, p_count);
		if (x>-1)
		{
			f[0] = x;
			p[0] = 1;
			return 1;
		}
	
		int k = 0;
		for (int i=0; i<p_count; i++)
		{	
			if (n < primes[i]*primes[i])
			{
				if (n>1)
				{
					p[k] = 1;
					f[k] = p_number(n, i, p_count-1);
					k++;
				}
			
				break;
			}
		
			if (n % primes[i] == 0)
			{
				f[k] = i;
				p[k] = 0;
				
				while (n % primes[i] == 0)
				{
					p[k]++;
					n /= primes[i];
				}
				k++;
			}
		}
		return k;
	}
	
	public int get_numbers(int[] f, int[] res)
	{
		int n =0;
		long x = 1;
		for (int k=0; k<p_count; k++)
		{
			for (;f[k]>0;f[k]--)
			{
				if (x * (long)primes[k] > 10000000)
				{
					res[n++] = (int)x;
					x = 1;
				}
				
				x *= primes[k];
			}
		}
		
		if (x>1)
		{
			res[n++] = (int)x;
		}
		
		if (n==0)
		{
			res[n++] = 1;
		}
		
		return n;
	}
	
	public int pow(int x, int k)
	{
		int r = 1;
		for (int s=32; s>0; s>>=1)
		{
			r*= r;
			if ((s & k) > 0)
			{
				r*= x;
			}
		}
		return r;
	}
	
	public void test()
	{
		int n = readInt();
		int m = readInt();
		
		int[] a = new int[n];
		int[] b = new int[m];
		
		int i,j,k;
		
		get_primes(10000000);
		
		int[] Fa = new int[p_count];
		int[] Fb = new int[p_count];
		Arrays.fill(Fa, 0);
		Arrays.fill(Fb, 0);
		
		int[] f = new int[p_count];
		int[] p = new int[p_count];
		
		for (i=0; i<n; i++)
		{
			k = factors(a[i] = readInt(), f, p);
			for (j=0; j<k; j++)
			{
				Fa[f[j]] += p[j];
			}
		}
		
		for (i=0; i<m; i++)
		{
			k = factors(b[i] = readInt(), f, p);
			for (j=0; j<k; j++)
			{
				Fb[f[j]] += p[j];
			}
		}
		
		for (i=0; i<p_count; i++)
		{
			k = Math.min(Fa[i], Fb[i]);
			Fa[i] -= k;
			Fb[i] -= k;
		}
		
		for (i=0; i<n; i++)
		{
			k = factors(a[i], f, p);
			a[i] = 1;
			for (j=0; j<k; j++)
			{
				a[i] *= pow(primes[f[j]], Math.min(p[j], Fa[f[j]]));
				Fa[f[j]] -= Math.min(p[j], Fa[f[j]]);
			}
		}
		
		for (i=0; i<m; i++)
		{
			k = factors(b[i], f, p);
			b[i] = 1;
			for (j=0; j<k; j++)
			{
				b[i] *= pow(primes[f[j]], Math.min(p[j], Fb[f[j]]));
				Fb[f[j]] -= Math.min(p[j], Fb[f[j]]);
			}
		}
		
		out.printf("%d %d\n", n, m);
		for (i=0; i<n; i++)
		{
			if (i>0)
			{
				out.print(" ");
			}
			out.print(a[i]);
		}
		out.println();
		
		for (i=0; i<m; i++)
		{
			if (i>0)
			{
				out.print(" ");
			}
			out.print(b[i]);
		}
		out.println();
		
		
	}
    
	public void run()
	{
		try
		{
			in = new BufferedReader(new InputStreamReader(System.in));
			out = System.out;
			
			//in = new BufferedReader(new FileReader("in.txt"));
			//out = new PrintStream(new File("out.txt"));
			
			
		}
		catch (Exception e)
		{
			return;
		}
		
		//while (true)
		{
			//int t = readInt(); for (int i=0; i<t; i++)					
			{
				test();
			}
		}
	}
	
	public static void main(String args[])
	{
		new Main().run();
	}
	
	private StringTokenizer tokenizer = null;
	
	public int readInt() 
	{
        return Integer.parseInt(readToken());
    }
   
    public long readLong() 
	{
        return Long.parseLong(readToken());
    }
   
    public double readDouble() 
	{
        return Double.parseDouble(readToken());
    }
   
	public String readLn()
	{	
		try
		{
			String s;
			while ((s = in.readLine()).length()==0);
			return s;
		}
		catch (Exception e)
		{
			return "";
		}
	}
	
    public String readToken() 
	{
		try
		{
			while (tokenizer == null || !tokenizer.hasMoreTokens()) 
			{
				tokenizer = new StringTokenizer(in.readLine());
			}
			return tokenizer.nextToken();
		}
		catch (Exception e)
		{
			return "";
		}
    }
	
	public int[] readIntArray(int n)
	{
		int[] x = new int[n];
		readIntArray(x, n);
		return x;
	}
	
	public void readIntArray(int[] x, int n)
	{
		for (int i=0; i<n; i++)
		{
			x[i] = readInt();
		}
	}
	
	public void logWrite(String format, Object... args)
	{
		if (!log_enabled)
		{
			return;
		}
		
		out.printf(format, args);
	}
}