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;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T bigmod(T p, T e, T M) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long int t = bigmod(p, e / 2, M);
    return (T)((t * t) % M);
  }
  return (T)((long long int)bigmod(p, e - 1, M) * (long long int)p) % M;
}
template <class T>
inline T bigexp(T p, T e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    long long int t = bigexp(p, e / 2);
    return (T)((t * t));
  }
  return (T)((long long int)bigexp(p, e - 1) * (long long int)p);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
int dx4[] = {1, 0, -1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int m, n, prf[10000007], prf1[10000003], prf3[10000005], p[1000000], c;
int st[(10010000 / 32) + 10];
int a[1000005], b[1000005];
bool check(int N, int pos) { return (N & 1 << pos); }
int sett(int N, int pos) { return N = (N | (1 << pos)); }
void sieve() {
  int sqt = (int)sqrt(10010000);
  for (int i = 3; i <= sqt; i += 2)
    if ((bool)check(st[i / 32], i % 32) == false)
      for (int j = i * i; j <= 10010000; j += (2 * i))
        st[j / 32] = sett(st[j / 32], j % 32);
  p[++c] = 2;
  for (int i = 3; i <= 10010000; i += 2)
    if ((bool)check(st[i / 32], i % 32) == false) p[++c] = i;
}
void pr_fctr(int x) {
  int sqt = int(sqrt((double)x));
  for (int i = 1; p[i] <= sqt && i <= c; i++) {
    if (x % p[i] == 0) {
      while (x % p[i] == 0) {
        x = x / p[i];
        prf[p[i]]++;
      }
      sqt = int(sqrt((double)x));
    }
  }
  if (x > 1) prf[x]++;
}
int pr_fctr1(int x) {
  int sqt = int(sqrt((double)x));
  int k = 1;
  for (int i = 1; p[i] <= sqt && i <= c; i++) {
    if (x % p[i] == 0) {
      while (x % p[i] == 0) {
        x = x / p[i];
        prf1[p[i]]++;
        if (prf[p[i]] > 0)
          prf[p[i]]--;
        else
          k *= p[i];
      }
      sqt = int(sqrt((double)x));
    }
  }
  if (x > 1) {
    prf1[x]++;
    if (prf[x] > 0)
      prf[x]--;
    else
      k *= x;
  }
  return k;
}
int pr_fctr2(int x) {
  int sqt = int(sqrt((double)x));
  int k = 1;
  for (int i = 1; p[i] <= sqt && i <= c; i++) {
    if (x % p[i] == 0) {
      while (x % p[i] == 0) {
        x = x / p[i];
        if (prf1[p[i]] > 0)
          prf1[p[i]]--;
        else
          k *= p[i];
      }
      sqt = int(sqrt((double)x));
    }
  }
  if (x > 1) {
    if (prf1[x] > 0)
      prf1[x]--;
    else
      k *= x;
  }
  return k;
}
int main() {
  sieve();
  scanf("%d %d", &n, &m);
  for (__typeof(n) i = (1); i <= (n); i++) {
    scanf("%d", &a[i]);
    pr_fctr(a[i]);
  }
  for (__typeof(m) i = (1); i <= (m); i++) {
    scanf("%d", &b[i]);
    b[i] = pr_fctr1(b[i]);
  }
  for (__typeof(n) i = (1); i <= (n); i++) {
    a[i] = pr_fctr2(a[i]);
  }
  printf("%d %d\n", n, m);
  for (__typeof(n) i = (1); i <= (n); i++) {
    if (i > 1) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
  for (__typeof(m) i = (1); i <= (m); i++) {
    if (i > 1) printf(" ");
    printf("%d", b[i]);
  }
  return 0;
}