#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, id;
  node() {}
  node(int a, int b) {
    v = a;
    id = b;
  }
};
bool operator<(const node& a, const node& b) { return a.v < b.v; }
multiset<node> mp;
int ans1[200200], ans2[200200];
node a[200200];
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    long long ans = 0;
    mp.clear();
    memset(ans1, 0, sizeof(ans1));
    memset(ans2, 0, sizeof(ans2));
    for (int i = 1; i <= n; i++) {
      node x;
      scanf("%d", &x.v);
      x.id = i;
      mp.insert(x);
    }
    for (int i = 1; i <= m; i++) {
      scanf("%d", &a[i].v);
      a[i].id = i;
    }
    sort(a + 1, a + m + 1);
    for (int i = 1; i <= m; i++) {
      int num = 0;
      int k = 0;
      while (a[i].v >= 1) {
        if (mp.find(node(a[i].v, 0)) != mp.end()) {
          ans += num;
          node tmp = *mp.find(node(a[i].v, 0));
          ans1[a[i].id] = num;
          ans2[tmp.id] = a[i].id;
          mp.erase(mp.find(node(a[i].v, 0)));
          break;
        }
        num++;
        a[i].v = (a[i].v + 1) >> 1;
        if (a[i].v == 1) k++;
        if (k > 1) break;
      }
    }
    printf("%d %lld\n", n - mp.size(), ans);
    for (int i = 1; i <= m; i++) printf("%d ", ans1[i]);
    puts("");
    for (int i = 1; i <= n; i++) printf("%d ", ans2[i]);
    puts("");
  }
  return 0;
}
