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.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.HashMap;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Alex
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	long MAX = 10000000;
    public void solve(int testNumber, InputReader in, OutputWriter out){
	    int n = in.ri(), m = in.ri();
	    int[] a = IOUtils.readIntArray(in, n), b = IOUtils.readIntArray(in, m);
	    int[] count = new int[(int) 1.01e7];
	    int[] primes = IntegerUtils.generatePrimes(3165);
	    HashMap<Integer, Integer>[] factorsa = new HashMap[n], factorsb = new HashMap[m];
	    for(int i = 0; i < n; i++) factorsa[i] = new HashMap<>();
	    for(int i = 0; i < m; i++) factorsb[i] = new HashMap<>();
	    for(int j = 0; j < a.length; j++) {
		    int i = a[j];
		    if(i > 1){
			    for(int prime : primes) {
				    while(i % prime == 0){
					    count[prime]++;
					    factorsa[j].merge(prime, 1, Integer::sum);
					    i /= prime;
				    }
				    if(prime > i) break;
			    }
			    if(i > 3165){
				    count[i]++;
				    factorsa[j].merge(i, 1, Integer::sum);
			    }
		    }
	    }
		for(int j = 0; j < b.length; j++){
			int i = b[j];
			if (i > 1){
				for(int prime : primes) {
					while(i % prime == 0){
						count[prime]--;
						factorsb[j].merge(prime, 1, Integer::sum);
						i /= prime;
					}
					if(prime > i) break;
				}
				if(i > 3165) {
					count[i]--;
					factorsb[j].merge(i, 1, Integer::sum);
				}
			}
		}
	    ArrayList<Integer> topres = new ArrayList<>(), bottomres = new ArrayList<>();
	    for(int j = 0; j < a.length; j++){
		    int i = a[j];
		    boolean works = true;
		    HashMap<Integer, Integer> thisis = factorsa[j];
		    for(Map.Entry<Integer, Integer> e : thisis.entrySet()){
			    if (count[e.getKey()] < e.getValue()) works = false;
		    }
		    if (works){
			    topres.add(i);
			    for(Map.Entry<Integer, Integer> e : thisis.entrySet()){
				    count[e.getKey()] -= e.getValue();
			    }
		    }
	    }
	    for(int j = 0; j < b.length; j++){
		    int i = b[j];
		    HashMap<Integer, Integer> thisis = factorsb[j];
		    boolean works = true;
		    for(Map.Entry<Integer, Integer> e : thisis.entrySet()){
			    if (-1*count[e.getKey()] < e.getValue()) works = false;
		    }
		    if (works){
			    bottomres.add(i);
			    for(Map.Entry<Integer, Integer> e : thisis.entrySet()){
				    count[e.getKey()] += e.getValue();
			    }
		    }
	    }
	    if (topres.size() == 0) topres.add(1);
	    if (bottomres.size() == 0) bottomres.add(1);
	    for(int i = count.length-1000; i >= 2; i--) {
		    while(count[i] > 0){
			    if ((long) topres.get(topres.size()-1) * i <= MAX)
				    topres.set(topres.size() - 1, topres.get(topres.size() - 1) * i);
			    else topres.add(i);
			    count[i]--;
		    }
		    while(count[i]<0){
			    if ((long) bottomres.get(bottomres.size()-1) * i <= MAX)
				    bottomres.set(bottomres.size() - 1, bottomres.get(bottomres.size() - 1) * i);
			    else bottomres.add(i);
			    count[i]++;
		    }
	    }
	    out.printLine(topres.size(), bottomres.size());
	    for(int i : topres) out.print(i + " ");
	    out.printLine();
	    for(int i : bottomres) out.print(i + " ");
    }
}

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

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public 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++];
	}
	public int ri(){
		return readInt();
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}
	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}
	public void printLine() {
		writer.println();
	}

    public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}
	public void close() {
		writer.close();
	}
}

class IOUtils {
	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readInt();
		return array;
	}
}

class IntegerUtils {
	public static int[] generatePrimes(int upTo) {
		int[] isPrime = generateBitPrimalityTable(upTo);
		IntList primes = new IntArrayList();
		for (int i = 0; i < upTo; i++) {
			if ((isPrime[i >> 5] >>> (i & 31) & 1) == 1)
				primes.add(i);
		}
		return primes.toArray();
	}
	public static int[] generateBitPrimalityTable(int upTo) {
		int[] isPrime = new int[(upTo + 31) >> 5];
		if (upTo < 2)
			return isPrime;
		Arrays.fill(isPrime, -1);
		isPrime[0] &= -4;
		for (int i = 2; i * i < upTo; i++) {
			if ((isPrime[i >> 5] >>> (i & 31) & 1) == 1) {
				for (int j = i * i; j < upTo; j += i)
					isPrime[j >> 5] &= -1 - (1 << (j & 31));
			}
		}
		return isPrime;
	}
}

abstract class IntCollection {
	public abstract IntIterator iterator();
	public abstract int size();
	public abstract void add(int value);
	public int[] toArray() {
		int size = size();
		int[] array = new int[size];
		int i = 0;
		for (IntIterator iterator = iterator(); iterator.isValid(); iterator.advance())
			array[i++] = iterator.value();
		return array;
	}
}

interface IntIterator {
	public int value() throws NoSuchElementException;
	public void advance() throws NoSuchElementException;
	public boolean isValid();
}
abstract class IntList extends IntCollection implements Comparable<IntList> {
	public abstract int get(int index);
	public IntIterator iterator() {
		return new IntIterator() {
			private int size = size();
			private int index = 0;

			public int value() throws NoSuchElementException {
				if (!isValid())
					throw new NoSuchElementException();
				return get(index);
			}

			public void advance() throws NoSuchElementException {
				if (!isValid())
					throw new NoSuchElementException();
				index++;
			}

			public boolean isValid() {
				return index < size;
			}
		};
	}
	public int hashCode() {
		int hashCode = 1;
		for (IntIterator i = iterator(); i.isValid(); i.advance())
			hashCode = 31 * hashCode + i.value();
		return hashCode;
	}

	public boolean equals(Object obj) {
		if (!(obj instanceof IntList))
			return false;
		IntList list = (IntList)obj;
		if (list.size() != size())
			return false;
		IntIterator i = iterator();
		IntIterator j = list.iterator();
		while (i.isValid()) {
			if (i.value() != j.value())
				return false;
			i.advance();
			j.advance();
		}
		return true;
	}

	public int compareTo(IntList o) {
		IntIterator i = iterator();
		IntIterator j = o.iterator();
		while (true) {
			if (i.isValid()) {
				if (j.isValid()) {
					if (i.value() != j.value()) {
						if (i.value() < j.value())
							return -1;
						else
							return 1;
					}
				} else
					return 1;
			} else {
				if (j.isValid())
					return -1;
				else
					return 0;
			}
			i.advance();
			j.advance();
		}
	}
}

class IntArrayList extends IntList {
	private int[] array;
	private int size;

	public IntArrayList() {
		this(10);
	}

	public IntArrayList(int capacity) {
		array = new int[capacity];
	}
	public int get(int index) {
		if (index >= size)
			throw new IndexOutOfBoundsException();
		return array[index];
	}
	public int size() {
		return size;
	}

	public void add(int value) {
		ensureCapacity(size + 1);
		array[size++] = value;
	}

	public void ensureCapacity(int newCapacity) {
		if (newCapacity > array.length) {
			int[] newArray = new int[Math.max(newCapacity, array.length << 1)];
			System.arraycopy(array, 0, newArray, 0, size);
			array = newArray;
		}
	}

	public int[] toArray() {
		int[] array = new int[size];
		System.arraycopy(this.array, 0, array, 0, size);
		return array;
	}
}