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

public class CodeForces {

    static int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
    static int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
    static final int INF = (int) 1e9 + 10;

    public static void main(String[] args) throws IOException {
        in.init(System.in);
        for (int i = 2; i*i <= isPrime.length; i++) if(!isPrime[i]){
            for (int j = i*2; j < isPrime.length; j += i) {
                isPrime[j] = true;
            }
        }
        
        
        int n = in.i(), m = in.i();
        arr = new int[n];
        brr = new int[m];
        
        for (int i = 0; i < n; i++) {
            arr[i] = in.i();
        }
        for (int i = 0; i < m; i++) {
            brr[i] = in.i();
        }
        
        factors(arr, arrF);
        factors(brr, brrF);
        
        for (int i = 2; i < arrF.length; i++) {
            int min = Math.min(arrF[i], brrF[i]);
            arrF[i] -= min;
            brrF[i] -= min;
        }
        
        System.out.println(n + " " + m);
        calc(arr, arrF);
        ans.append('\n');
        calc(brr, brrF);
        
        System.out.print(ans);
    }
    
    static int max = (int)1e7+1;
    static boolean isPrime[] = new boolean[max];
    static int arrF[] = new int[max];
    static int brrF[] = new int[max];
    static int arr[];
    static int brr[];
    static StringBuilder ans = new StringBuilder();
    
    static void factors(int arr[], int f[]){
        for (int i = 0; i < arr.length; i++) {
            int x = arr[i];
            for (int j = 2; j*j <= x; j++) {
                while(x % j == 0){
                    x /= j;
                    f[j]++;
                }
                
                if(!isPrime[x])
                    break;
            }
            
            if(x != 1)
                f[x]++;
        }
    }
    
    static void calc(int arr[], int f[]){
        for (int i = 0; i < arr.length; i++) {
            int x = 1;
            for (int j = 2; j*j <= arr[i]; j++) {
                while(arr[i] % j == 0){
                    arr[i] /= j;
                    
                    if(f[j] > 0)
                        x *= j;
                    f[j]--;
                }
                
                if(!isPrime[arr[i]])
                    break;
            }
            
            if(arr[i] != 1 && f[arr[i]] > 0){
               x *= arr[i];
               f[arr[i]]--;
            }
        
            ans.append(x).append(' ');
        }
        
        
    }
}

class Queue {

    int first = -1, last = -1, size = 0;
    long arr[];

    Queue(int n) {
        arr = new long[n + 10];
    }

    long pop() {
        size--;
        return arr[++first];
    }

    void push(long x) {
        size++;
        arr[++last] = x;
    }

    boolean isEmpty() {
        return first == last;
    }
}

class Pair implements Comparable<Pair> {

    int x;
    int y;

    Pair(int a, int b) {
        x = a;
        y = b;
    }

    @Override
    public int compareTo(Pair t) {
        return x - t.x;
    }

    @Override
    public int hashCode() {
        return 1;
    }

    @Override
    public boolean equals(Object o) {
        return ((Pair) o).x == x && ((Pair) o).y == y;
    }

}

class in {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

    static String n() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int i() throws IOException {
        return pars(n());
    }

    static long l() throws IOException {
        return Long.parseLong(n());
    }

    static double d() throws IOException {
        return Double.parseDouble(n());
    }
}