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;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
template <typename T, typename... Args>
inline string arrStr(T arr, int n) {
  stringstream s;
  s << "[";
  for (int i = 0; i < n - 1; i++) s << arr[i] << ",";
  s << arr[n - 1] << "]";
  return s.str();
}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template <typename T>
inline void __evars_out_var(vector<T> val) {
  cerr << arrStr(val, val.size());
}
template <typename T>
inline void __evars_out_var(T *val) {
  cerr << arrStr(val, 10);
}
template <typename T>
inline void __evars_out_var(T val) {
  cerr << val;
}
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template <typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
  __evars_out_var(a);
  cerr << "; ";
  __evars(++it, args...);
}
const long long nmax = 1000 * 1007;
struct edge {
  long long a, b, cost;
  edge(long long x, long long y, long long z) : a(x), b(y), cost(z){};
};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<long long> prime;
long long freq[10000005] = {0};
vector<long long> cnta(7e6, 0);
vector<long long> cntb(7e6, 0);
vector<pair<long long, long long> > resa, resb;
vector<long long> fina, finb;
void pre() {
  long long N = 1e7 + 5;
  for (long long i = 2; i < N; i++) {
    if (!freq[i]) {
      for (long long j = 2; i * j < N; j++) {
        freq[i * j] = i;
      }
      prime.push_back(i);
      freq[i] = i;
    }
  }
}
void work(vector<long long> &a, vector<long long> &cnta) {
  long long n = a.size();
  for (long long i = 0; i < (long long)(n); i++) {
    long long tmp = a[i];
    while (tmp > 1) {
      long long idx = lower_bound((prime).begin(), (prime).end(), freq[tmp]) -
                      prime.begin();
      tmp /= freq[tmp];
      cnta[idx]++;
    }
  }
}
void print(vector<long long> &a, vector<long long> &cnta) {
  long long n = a.size();
  for (long long i = 0; i < (long long)(n); i++) {
    long long tmp = a[i];
    long long ans = 1;
    while (tmp > 1) {
      long long idx = lower_bound((prime).begin(), (prime).end(), freq[tmp]) -
                      prime.begin();
      if (cnta[idx]) {
        cnta[idx]--;
        ans *= freq[tmp];
      }
      tmp /= freq[tmp];
    }
    cout << ans << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  pre();
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n), b(m);
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  for (long long i = 0; i < (long long)(m); i++) cin >> b[i];
  work(a, cnta);
  work(b, cntb);
  long long ansa = 0, ansb = 0;
  for (long long i = 0; i < (long long)(cnta.size()); i++) {
    long long mini = min(cnta[i], cntb[i]);
    cnta[i] -= mini;
    cntb[i] -= mini;
  }
  cout << n << " " << m << endl;
  print(a, cnta);
  cout << "\n";
  print(b, cntb);
  return 0;
}