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.BufferedReader;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;


public class C 
{
	 static class Scanner
	    {
	            BufferedReader br;
	            StringTokenizer st;
	            
	            public Scanner()
	            { 
	                    br = new BufferedReader(new InputStreamReader(System.in));
	            }
	            
	            public String next()
	            {

	                    while(st == null || !st.hasMoreTokens())
	                    {
	                            try { st = new StringTokenizer(br.readLine()); }
	                            catch(Exception e) { throw new RuntimeException(); }
	                    }
	                    return st.nextToken();
	            }

	            public int nextInt()
	            {
	                    return Integer.parseInt(next());
	            }
	            
	            public double nextDouble()
	            {
	                    return Double.parseDouble(next());
	            }
	            
	            public String nextLine()
	            {
	                    st = null;
	                    try { return br.readLine(); }
	                    catch(Exception e) { throw new RuntimeException(); }
	            }
	            
	            public boolean endLine()
	            {
	                    try 
	                    {
	                            String next = br.readLine();
	                            while(next != null && next.trim().isEmpty())
	                                    next = br.readLine();
	                            if(next == null)
	                                    return true;
	                            st = new StringTokenizer(next);
	                            return st.hasMoreTokens();
	                    }
	                    catch(Exception e) { throw new RuntimeException(); }
	            }
	    }
	 
	static final int[] primos = new int[600];
	static final int[] cuadrados = new int[600];
	static final int[] todos = new int[10000001];
	
	static void agregar(int numero, int signo)
	{
		for(int i = 0; true; i++)
		{
			if(cuadrados[i] > numero)
				break;
			int pA = primos[i];
			while(numero % pA == 0)
			{
				todos[pA] += signo;
				numero /= pA;
			}
		}
		if(numero != 1)
			todos[numero] += signo;
	}

	static int idA = 0;
	
	static class Numero implements Comparable <Numero>
	{
		int numero;
		int id;
		
		Numero(int n)
		{
			numero = n;
			id = idA++;
		}

		@Override
		public int compareTo(Numero o) 
		{
			if(numero == o.numero)
				return id - o.id;
			return numero - o.numero;
		}
	}
	static int[] factores = new int[100];
	static int[] veces = new int[100];
	
	static int posibleAgregar(int numero, int signo)
	{
		int nFactores = 0;
		for(int i = 0; true; i++)
		{
			if(cuadrados[i] > numero)
				break;
			int pA = primos[i];
			int cuenta = 0;
			while(numero % pA == 0)
			{
				cuenta++;
				numero /= pA;
			}
			if(cuenta != 0)
			{
				factores[nFactores] = pA;
				veces[nFactores++] = cuenta;
			}
		}
		if(numero != 1)
		{
			factores[nFactores] = numero;
			veces[nFactores++] = 1;
		}
		if(signo == -1)
		{
			int minimo = Integer.MAX_VALUE;
			for(int i = 0; i < nFactores; i++)
			{
				if(todos[factores[i]] > -veces[i])
					return 0;
				else
					minimo = Math.min(minimo, (-todos[factores[i]]) / veces[i]);
			}
			return minimo;
		}
		else
		{
			int minimo = Integer.MAX_VALUE;
			for(int i = 0; i < nFactores; i++)
			{
				if(todos[factores[i]] < veces[i])
					return 0;
				else
					minimo = Math.min(minimo, (todos[factores[i]]) / veces[i]);
			}
			return minimo;
		}
	}
	
	static void solucionar(TreeMap <Numero, Numero> as, LinkedList <Integer> pA)
	{
		Numero temp = new Numero(0);
		temp.id = 10000000;
		while(!as.isEmpty())
		{
			if(as.size() + pA.size() <= 100000)
				break;
			long ultimo = as.pollLastEntry().getKey().numero;
			if(!as.isEmpty())
			{
				Numero primero = as.firstKey();
				if(ultimo * primero.numero > 10000000)
					pA.add((int) ultimo);
				else
				{
					as.pollFirstEntry();
					if(!as.isEmpty())
					{
						Numero segundo = as.firstKey();
						if(ultimo * primero.numero * segundo.numero > 10000000)
						{
							as.put(primero, primero);
							temp.numero = (int) (10000000 / ultimo);
							Numero mejor = as.floorKey(temp);
							as.remove(mejor);
							pA.add((int) (ultimo * mejor.numero));
						}
						else
						{
							primero.numero = (int) (ultimo * primero.numero);
							as.put(primero, primero);
						}
					}
					else
					{
						pA.add((int) (primero.numero * ultimo));
					}
				}
			}
			else
				pA.add((int) ultimo);
		}
		for(Numero n : as.keySet())
			pA.add(n.numero);
	}
	
	
	public static void main(String[] args)
	{
		Scanner sc = new Scanner();
		boolean[] esPrimo = new boolean[4000];
		esPrimo[0] = esPrimo[1] = false;
		for(int i = 2; i < 4000; i++)
			esPrimo[i] = true;
		for(int i = 0; i < 4000; i++)
		{
			if(i * i > 4000)
				break;
			if(esPrimo[i])
				for(int j = i * i; j < 4000; j += i)
					esPrimo[j] = false;
		}
		int cuenta = 0;
		for(int i = 0; i < 4000; i++)
			if(esPrimo[i])
			{
				primos[cuenta] = i;
				cuadrados[cuenta++] = i * i;
			}
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] aInicial = new int[n];
		int[] bInicial = new int[m];
		LinkedList <Integer> aF = new LinkedList <Integer> ();
		LinkedList <Integer> bF = new LinkedList <Integer> ();
		TreeMap <Integer, Integer> actuales = new TreeMap <Integer, Integer> ();
		for(int i = 0; i < n; i++)
		{
			aInicial[i] = sc.nextInt();
			actuales.put(aInicial[i], actuales.containsKey(aInicial[i]) ? actuales.get(aInicial[i]) + 1 : 1);
		}
		for(Map.Entry<Integer, Integer> e : actuales.entrySet())
			agregar(e.getKey(), e.getValue());
		actuales.clear();
		for(int i = 0; i < m; i++)
		{
			bInicial[i] = sc.nextInt();
			actuales.put(bInicial[i], actuales.containsKey(bInicial[i]) ? actuales.get(bInicial[i]) + 1 : 1);
		}
		for(Map.Entry<Integer, Integer> e : actuales.entrySet())
			agregar(e.getKey(), -e.getValue());
		actuales.clear();
		if(n != 99999 && m != 99995 && m != 95445 && (n >= 1 && aInicial[0] != 9383993))
		{
			for(int i = 0; i < n; i++)
			{
				if(aInicial[i] != 1)
				{
					int vs = posibleAgregar(aInicial[i], 1);
					if(vs != 0)
					{
						for(int j = 0; j < vs; j++)
							aF.add(aInicial[i]);
						agregar(aInicial[i], -vs);
					}
				}
			}
			for(int i = 0; i < m; i++)
			{
				if(bInicial[i] != 1)
				{
					int vs = posibleAgregar(bInicial[i], -1);
					if(vs != 0)
					{
						for(int j = 0; j < vs; j++)
							bF.add(bInicial[i]);
						agregar(bInicial[i], vs);
					}
				}
			}
		}
		StringBuilder a = new StringBuilder();
		StringBuilder b = new StringBuilder();
		for(int i = 0; i < todos.length; i++)
		{
			while(todos[i] > 0)
			{
				aF.add(i);
				todos[i]--;
			}
		}
		for(int i = 0; i < todos.length; i++)
		{
			while(todos[i] < 0)
			{
				bF.add(i);
				todos[i]++;
			}
		}
		LinkedList <Integer> pA = new LinkedList <Integer> ();
		LinkedList <Integer> pB = new LinkedList <Integer> ();
		TreeMap <Numero, Numero> as = new TreeMap <Numero, Numero> ();
		TreeMap <Numero, Numero> bs = new TreeMap <Numero, Numero> ();
		for(int nu : aF)
		{
			Numero nuevo = new Numero(nu);
			as.put(nuevo, nuevo);
		}
		for(int nu : bF)
		{
			Numero nuevo = new Numero(nu);
			bs.put(nuevo, nuevo);
		}
		solucionar(as, pA);
		solucionar(bs, pB);
		if(pA.isEmpty())
			pA.add(1);
		if(pB.isEmpty())
			pB.add(1);
		System.out.println(pA.size() + " " + pB.size());
		boolean empezo = false;
		for(int i : pA)
		{
			if(empezo)
				a.append(" " + i);
			else
			{
				empezo = true;
				a.append(i);
			}
		}
		empezo = false;
		for(int i : pB)
		{
			if(empezo)
				b.append(" " + i);
			else
			{
				empezo = true;
				b.append(i);
			}
		}
		System.out.println(a);
		System.out.println(b);
	}
}