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 CodeForces extends Functions {

    private static void solve() {
        int max = (int)1e7+1;
        int n = sc.nextInt();
        int d = sc.nextInt();
        int[] numerator = sc.setintArray(n);
        int[] denominator = sc.setintArray(d);
        int[] primeDivisor = new int[max];
        for(int val=2;val<max;val++)primeDivisor[val]= val;
        for(int val=2;val*val<max;val++)
            if(primeDivisor[val]==val){
                for(int multiple = val*val;multiple<max;multiple+=val)
                    primeDivisor[multiple] = val;
            }

        int[] divisorCountNumerator = calcDivisorCount(numerator,max,primeDivisor);
        int[] divisorCountDenominator = calcDivisorCount(denominator,max,primeDivisor);
        for(int val=2;val<max;val++)
            divisorCountNumerator[val] = divisorCountDenominator[val] = Math.min(divisorCountDenominator[val],divisorCountNumerator[val]);
        reduceNumbers(numerator,divisorCountNumerator,primeDivisor);
        reduceNumbers(denominator,divisorCountDenominator,primeDivisor);
        out.println(n+" "+d);
        StringBuilder sb = new StringBuilder();
        for(int ele : numerator)sb.append(ele).append(" ");
        sb.append('\n');
        for(int ele : denominator)sb.append(ele).append(" ");
        out.println(sb);



    }
    private static int[] calcDivisorCount(int[] arr,int max,int[] primeDivisor){
        int[] divisorCount = new int[max];
        for(int ele : arr){
            while (ele>1){
               divisorCount[primeDivisor[ele]]++;
               ele/=primeDivisor[ele];
            }
        }
        return divisorCount;
    }
    private static void reduceNumbers(int[] arr,int[] divisorCount,int[] primeDivisor){
        for(int i=0;i<arr.length;i++){
            int num = arr[i];
            while (num>1){
                if(divisorCount[primeDivisor[num]]>0) {
                    arr[i] /= primeDivisor[num];
                    divisorCount[primeDivisor[num]]--;
                }
                num/=primeDivisor[num];
            }
        }
    }
    public static void main(String[] args) {
        int testCase = 1;
//        testCase= sc.nextInt();

        while (testCase-->0) solve();
        sc.close();
        out.flush();
        out.close();
    }

    static Scanner sc = new Scanner(); // Input
    static  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  // output
//    static PrintStream out = new PrintStream(System.out);
}


class Functions {
    public static long mod = (long)1e9+7L;
    public static final int INT_MAX = Integer.MAX_VALUE;
    public static final int INT_MIN = Integer.MIN_VALUE;
    public static final long LONG_MAX = Long.MAX_VALUE;
    public static final long LONG_MIN = Long.MIN_VALUE;
    public static final double DOUBLE_MAX = Double.MAX_VALUE;
    public static final double DOUBLE_MIN = Double.MIN_VALUE;
    public static final String YES = "YES";
    public static final String NO = "NO";

    public static void sort(int[] a,boolean isAscending){
        ArrayList<Integer> temp = new ArrayList<>();
        for (int j : a) temp.add(j);
        sort(temp,isAscending);
        for(int i=0;i<a.length;i++)a[i] = temp.get(i);
    }

    public static void sort(List list,boolean isAscending){
        if(isAscending)
            Collections.sort(list);
        else Collections.sort(list,Collections.reverseOrder());
    }
    // euclidean algorithm
    public static long gcd(long a, long b) {
        // time O(max (loga ,logb))
        long x = Math.min(a,b);
        long y = Math.max(a,b);
        if (y % x == 0) return x;
        return gcd(y%x,x);
    }
    public static long lcm(long a, long b) {
        // lcm(a,b) * gcd(a,b) = a * b
        return (a / gcd(a, b)) * b;
    }

    public static long factorial(long n){
        long fact = 1L;
        for(int i=2;i<=n;i++)fact = (fact*i)%mod;
        return fact;
    }
    public static long firstDivisor(long n){
        if(n==1)return n;
        for(long i=2;i*i<=n;i++)
            if(n%i==0)return i;
        return -1;
    }
    public static long power(long x,long n){
        // calculate x^n %mod using binary exponentiation
        // time : O(logn)
        long ans = 1;
        while(n>0){
            if(n%2!=0){
                ans *= x;
                n--;
            }else {
                x *= x;
                n/=2;
            }
            x %=mod;
            ans %=mod;
        }
        return ans;
    }
    public  static int ncr(int n, int r){
        // time O(n+r)
        if (r > n)
            return 0;
        long[] inv = new long[r + 1];
        inv[1] = 1;
        // Getting the modular inversion
        // for all the numbers
        // from 2 to r with respect to m
        for (int i = 2; i <= r; i++) {
            inv[i] = mod - (mod / i) * inv[(int) (mod % i)] % mod;
        }
        int ans = 1;
        // for 1/(r!) part
        for (int i = 2; i <= r; i++) {
            ans = (int) (((ans % mod) * (inv[i] % mod)) % mod);
        }
        // for (n)*(n-1)*(n-2)*...*(n-r+1) part
        for (int i = n; i >= (n - r + 1); i--) {
            ans = (int) (((ans % mod) * (i % mod)) % mod);
        }
        return ans;
    }
    public static void reverseArray(int[] a){
        int left = 0;
        int right = a.length-1;
        while (left<right){
            int temp =a[left];
            a[left] = a[right];
            a[right] = temp;
            left++;
            right--;
        }
    }
}

class Scanner {
    private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private StringTokenizer st = new StringTokenizer("");
    public String next(){
        while (!st.hasMoreTokens())
            try {
                st = new StringTokenizer(br.readLine());
            }catch (IOException e){
                e.printStackTrace();
            }
        return st.nextToken();

    }
    public int nextInt(){return Integer.parseInt(next());}
    public long nextLong(){return Long.parseLong(next());}
    public double nextDouble(){return Double.parseDouble(next());}
    public int[] setintArray(int n){
        int[] arr =new int[n];
        for(int i=0;i<n;i++)arr[i] = nextInt();
        return arr;
    }
    public long[] setlongArray(int n){
        long[] arr =new long[n];
        for(int i=0;i<n;i++)arr[i] = nextLong();
        return arr;
    }
    public int[][] set2DintArray(int row, int col){
        int[][] arr = new int[row][col];
        for(int i=0;i<row;i++)
            for(int j= 0;j<col;j++)
                arr[i][j] = nextInt();
        return arr;
    }
    public long[][] set2DlongArray(int row, int col){
        long[][] arr = new long[row][col];
        for(int i=0;i<row;i++)
            for(int j= 0;j<col;j++)
                arr[i][j] = nextLong();
        return arr;
    }
    public void close(){
        try{
            br.close();
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}