#include <bits/stdc++.h>
const int maxn = 2e5 + 10;
using namespace std;
long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }
long long qpow(long long p, long long q) {
  long long f = 1;
  while (q) {
    if (q & 1) f = f * p;
    p = p * p;
    q >>= 1;
  }
  return f;
}
inline long long read() {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, k, t, p[maxn], s[maxn], vis[maxn], vis1[maxn], used[maxn], c, u;
queue<pair<int, int> > pq;
set<pair<int, int> > q;
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &p[i]), q.insert(make_pair(p[i], i));
  for (i = 1; i <= m; i++) scanf("%d", &s[i]), pq.push(make_pair(s[i], i));
  while (!pq.empty()) {
    pair<int, int> x = pq.front();
    pq.pop();
    bool flag = false;
    auto it = q.lower_bound(make_pair(x.first, 0));
    if (it != q.end() && it->first == x.first) {
      vis[it->second] = x.second;
      vis1[x.second] = it->second;
      flag = true;
      q.erase(it);
    }
    if (!flag) {
      if (x.first != 1) {
        if (x.first & 1) x.first++;
        x.first >>= 1;
        used[x.second]++;
        pq.push(make_pair(x.first, x.second));
      }
    }
  }
  for (i = 1; i <= n; i++)
    if (vis[i]) c++;
  for (i = 1; i <= m; i++)
    if (vis1[i]) u += used[i];
  printf("%d %d\n", c, u);
  for (i = 1; i <= m; i++) {
    if (vis1[i])
      printf("%d ", used[i]);
    else
      printf("0 ");
  }
  printf("\n");
  for (i = 1; i <= n; i++) printf("%d ", vis[i]);
  printf("\n");
  return 0;
}
