#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;
struct cT {
  cT() : cho(0) {}
  int id, p, cho;
} com[MAXN];
struct qT {
  qT() {}
  qT(int _id, int _p, int _cc) : id(_id), p(_p), cc(_cc) {}
  bool operator<(const qT &a) const {
    return ((p ^ a.p) ? (p < a.p) : ((cc ^ a.cc) ? (cc > a.cc) : (id > a.id)));
  }
  int id, p, cc;
} now;
int n, m;
int s[MAXN], ad[MAXN];
priority_queue<qT> q;
void init();
void input();
void work();
bool cmp_s(const cT &a, const cT &b) {
  return ((a.p ^ b.p) ? (a.p > b.p) : (a.id > b.id));
}
bool cmp_id(const cT &a, const cT &b) { return (a.id < b.id); }
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d", &com[i].p);
  for (int i = 1; i <= m; ++i) scanf("%d", &s[i]);
}
void work() {
  for (int i = 0; i < n; ++i) com[i].id = i;
  sort(com, com + n, cmp_s);
  for (int i = 1; i <= m; ++i) q.push(qT(i, s[i], 0));
  memset(ad, 0, sizeof(ad));
  int ans = 0, ok = 0;
  for (int i = 0; i < n; ++i) {
    while (1) {
      if (q.empty()) break;
      now = q.top();
      if (now.p > com[i].p) {
        now.p = (now.p + 1) / 2;
        ++now.cc;
        q.pop();
        q.push(now);
      } else if (now.p == com[i].p) {
        q.pop();
        com[i].cho = now.id;
        ans += now.cc;
        ad[now.id] = now.cc;
        ++ok;
        break;
      } else {
        break;
      }
    }
    if (q.empty()) break;
  }
  sort(com, com + n, cmp_id);
  printf("%d %d\n", ok, ans);
  for (int i = 1; i <= m; ++i) printf("%d ", ad[i]);
  printf("\n");
  for (int i = 0; i < n; ++i) printf("%d ", com[i].cho);
  printf("\n");
}
