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 PYTHON3):

Solution:
from collections import defaultdict
import bisect
from itertools import accumulate
import os
import sys
import math
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input(): return sys.stdin.readline().rstrip("\r\n")


# ------------------- fast io --------------------
def factor(n, dic1):
    while(n % 2 == 0):
        if 2 not in dic1:
            dic1[2] = 1
        else:
            dic1[2] += 1
        n = n//2
    for i in range(3, int(math.sqrt(n))+1, 2):
        while(n % i == 0):
            if i not in dic1:
                dic1[i] = 1
            else:
                dic1[i] += 1
            n = n//i
    if n > 2:
        if n not in dic1:
            dic1[n] = 1
        else:
            dic1[n] += 1


def factor1(n, dic2):
    while(n % 2 == 0):
        if 2 not in dic2:
            dic2[2] = 1
        else:
            dic2[2] += 1
        n = n//2
    for i in range(3, int(math.sqrt(n))+1, 2):
        if n % i == 0:
            while(n % i == 0):
                if i not in dic2:
                    dic2[i] = 1
                else:
                    dic2[i] += 1
                n = n//i
    if n > 2:
        if n not in dic2:
            dic2[n] = 1
        else:
            dic2[n] += 1


n, m = map(int, input().split())
dic1 = {}
dic2 = {}
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
for i in range(0, len(a)):
    factor(a[i], dic1)
for i in range(0, len(b)):
    factor1(b[i], dic2)
ans1 = [1]*n
ans2 = [1]*m
fac1 = []
fac2 = []
for key in dic1:
    if key in dic2:
        if dic1[key] >= dic2[key]:
            dic1[key] -= dic2[key]
            dic2[key] = 0
        elif dic2[key] > dic1[key]:
            dic2[key] -= dic1[key]
            dic1[key] = 0
fac11=[]
fac22=[]
for key in dic1:
    fac11.append([key,dic1[key]])
for key in dic2:
    fac22.append([key,dic2[key]])
fac11.sort(reverse=True)
fac22.sort(reverse=True)
j=0
for i in range(0,len(fac11)):
    while(fac11[i][1]>0):
        if ans1[j]*fac11[i][0]<=10**7:
            ans1[j]=ans1[j]*fac11[i][0]
            fac11[i][1]-=1
        j=(j+1)%n
j=0
for i in range(0, len(fac22)):
    while(fac22[i][1] > 0):
        if ans2[j]*fac22[i][0] <= 10**7:
            ans2[j] = ans2[j]*fac22[i][0]
            fac22[i][1] -= 1
        j = (j+1) % m
print(len(ans1),len(ans2))
print(*ans1)
print(*ans2)