#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
map<int, int> mp;
int n, m, x, nxt[200005], ansa[200005], ansb[200005];
struct Node {
  int x, id;
} f[200005];
bool cmp(Node a, Node b) { return a.x < b.x; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    if (mp.count(x) != 0) {
      nxt[i] = mp[x];
    }
    mp[x] = i;
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &f[i].x);
    f[i].id = i;
  }
  sort(f + 1, f + m + 1, cmp);
  for (int i = 1; i <= m; ++i) {
    x = f[i].x;
    int dq = 0;
    while (x != 0) {
      if (mp.count(x) == 0 || mp[x] == 0) {
        dq++;
        if (x == 1)
          x = 0;
        else
          x = (x + 1) / 2;
      } else {
        ansa[mp[x]] = f[i].id;
        ansb[f[i].id] = dq;
        mp[x] = nxt[mp[x]];
        break;
      }
    }
  }
  int suma = 0, sumb = 0;
  for (int i = 1; i <= n; ++i)
    if (ansa[i] != 0) suma++;
  for (int i = 1; i <= m; ++i) sumb += ansb[i];
  printf("%d %d\n", suma, sumb);
  for (int i = 1; i <= m; ++i) printf("%d ", ansb[i]);
  printf("\n");
  for (int i = 1; i <= n; ++i) printf("%d ", ansa[i]);
  return 0;
}
