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

Solution:
#include <bits/stdc++.h>
using namespace std;
const char al[100] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                      'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                      'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> nums(n + 1);
  vector<int> op(10000000 + 1, false);
  vector<int> prost;
  for (int i = 2; i <= 10000000; ++i) {
    if (op[i] == 0) {
      op[i] = i;
      prost.push_back(i);
    }
    for (int j = 0;
         j < (int)prost.size() && prost[j] <= op[i] && i * prost[j] <= 10000000;
         ++j)
      op[i * prost[j]] = prost[j];
  }
  map<long long int, long long int> my;
  long long int x;
  long long int j;
  long long int count = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> x;
    nums[i] = x;
    j = 0;
    if (op[x] == x) {
      count++;
      my[x]++;
    } else {
      while (x > 1) {
        if (op[x] != x) {
          while (x % prost[j] != 0) j++;
          x /= prost[j];
          my[prost[j]]++;
          count++;
        } else {
          my[x]++;
          count++;
          x = 0;
        }
      }
    }
  }
  vector<long long int> second;
  for (long long int i = 0; i < m; i++) {
    cin >> x;
    j = 0;
    if (op[x] == x) {
      if (my.find(x) != my.end() && my[x] > 0) {
        my[x]--;
        count--;
      } else {
        if (second.size() != 0 && second[second.size() - 1] * x <= 10000000)
          second[second.size() - 1] *= x;
        else
          second.push_back(x);
      }
    } else {
      while (x > 1) {
        if (op[x] != x) {
          while (x % prost[j] != 0) j++;
          x /= prost[j];
          if (my.find(prost[j]) != my.end() && my[prost[j]] > 0) {
            my[prost[j]]--;
            count--;
          } else {
            if (second.size() != 0 &&
                second[second.size() - 1] * prost[j] <= 10000000)
              second[second.size() - 1] *= prost[j];
            else
              second.push_back(prost[j]);
          }
        } else {
          if (my.find(x) != my.end() && my[x] > 0) {
            my[x]--;
            count--;
          } else {
            if (second.size() != 0 && second[second.size() - 1] * x <= 10000000)
              second[second.size() - 1] *= x;
            else
              second.push_back(x);
          }
          x = 0;
        }
      }
    }
  }
  long long int prev = 1;
  long long int o;
  long long int value;
  vector<long long int> ans;
  vector<pair<int, int> > ssort;
  map<long long int, long long int> now;
  int pre = 1;
  for (int i = 0; i < n; i++) {
    pre = 1;
    x = nums[i];
    j = 0;
    while (x > 1) {
      if (op[x] == x) {
        now[x]++;
        if (now[x] <= my[x]) pre *= x;
        x = 1;
      } else {
        while (x % prost[j] != 0) j++;
        x /= prost[j];
        now[prost[j]]++;
        if (now[prost[j]] <= my[prost[j]]) pre *= prost[j];
      }
    }
    ans.push_back(pre);
  }
  if (second.size() == 0) second.push_back(1);
  cout << ans.size() << " " << second.size() << endl;
  for (long long int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
  for (long long int i = 0; i < second.size(); i++) cout << second[i] << " ";
}