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

public class ReducingFractions {
	public static void main(String[] args) throws IOException {
		BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(rd.readLine());
		N = Integer.parseInt(st.nextToken());
		M = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(rd.readLine());
		A = new int[N];
		for(int i=0; i<N; i++) A[i] = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(rd.readLine());
		B = new int[M];
		for(int i=0; i<M; i++) B[i] = Integer.parseInt(st.nextToken());
		boolean[] not_pr = new boolean[4001];
		for(int i=2; i<not_pr.length; i++){
			for(int j=2; j*i<not_pr.length; j++){
				not_pr[i*j] = true;
			}
		}
		G = new ArrayList[N+1];
		H = new ArrayList[M+1];
		for(int i=0; i<G.length; i++) G[i] = new ArrayList<Integer>();
		for(int i=0; i<H.length; i++) H[i] = new ArrayList<Integer>();
		int psz = 0;
		for(int i=2; i<not_pr.length; i++) if(!not_pr[i]) psz++;
		P = new int[psz];
		int k = 0;
		for(int i=2; i<not_pr.length; i++) if(!not_pr[i]){
			P[k] = i;
			k++;
		}
		for(int i=0; i<N; i++){
			addAllDivisors(i, MM1, true);
			if(G[i].size()==0) G[i].add(A[i]);
		}
		for(int i=0; i<M; i++){
			addAllDivisors(i, MM2, false);
			if(H[i].size()==0) H[i].add(B[i]);
		}
		for(int i=0; i<N; i++){
			for(int j=0; j<G[i].size(); j++){
				int num = G[i].get(j);
				int pow = MM1[num];
				if(MM2[num]>0){
					int pow2 = MM2[num];
					if(pow<pow2){
						MM1[num] = 0;
						MM2[num] = pow2-pow;
					}
					else if(pow>pow2){
						MM2[num] = 0;
						MM1[num] = pow-pow2;
					}
					else{
						MM1[num] = 0;
						MM2[num] = 0;
					}
				}
			}
		}
		ArrayList<Integer> ans1 = new ArrayList<Integer>(), ans2 = new ArrayList<Integer>();
		for(int i=0; i<N; i++){
			int X = A[i];
			for(int j=0; j<G[i].size(); j++){
				int s = 0;
				int pr = G[i].get(j);
				if(pr==1) continue;
				while(X%pr==0){
					s++;
					X /= pr;
				}
				int left = Math.min(MM1[pr], s);
				for(int t=0; t<left; t++) X *= pr;
				MM1[pr] -= Math.min(MM1[pr], s);
			}
			ans1.add(X);
		}
		for(int i=0; i<M; i++){
			int X = B[i];
			for(int j=0; j<H[i].size(); j++){
				int s = 0;
				int pr = H[i].get(j);
				if(pr==1) continue;
				while(X%pr==0){
					X /= pr;
					s++;
				}
				int numleft = Math.min(MM2[pr], s);
				for(int t=0; t<numleft; t++) X *= pr;
				MM2[pr] -= Math.min(MM2[pr], s);
			}
			ans2.add(X);
		}
		if(ans1.size()==0) ans1.add(1);
		if(ans2.size()==0) ans2.add(1);
		pw.println(ans1.size()+" "+ans2.size());
		for(int i=0; i<ans1.size(); i++) pw.print(ans1.get(i)+" ");
		pw.println();
		for(int i=0; i<ans2.size(); i++) pw.print(ans2.get(i)+" ");
		pw.println();
		pw.flush();
	}
	
	static void addAllDivisors(int X, int[] MM, boolean first){
		ArrayList<Integer> T = first? G[X]: H[X];
		X = first? A[X]: B[X];
		int mult = 1;
		for(int t=0; t<P.length; t++){
			int i = P[t];
			if(X%i==0){
				T.add(i);
				while(X%i==0){
					X /= i;
					MM[i]++;
					mult *= i;
				}
			}
		}
		if(X>1){
			MM[X]++;
			T.add(X);
		}
	}
	
	
	static ArrayList<Integer>[] G, H;
	
	static int[] MM1 = new int[10000009], MM2 = new int[10000009];
		
	static int[] A, B, P;
	static int N, M;
	
}