#include <bits/stdc++.h>
using namespace std;
const int N = 200008;
int p[N];
int s[N];
int a[N];
int b[N];
pair<int, int> pp[N];
set<pair<int, int> > ss;
int get(int s, int p) {
  int ret = 0;
  while (s != p) {
    s = ceil(s / 2.0);
    ++ret;
  }
  return ret;
}
int main() {
  int n = 0;
  int m = 0;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", p + i);
    pp[i] = make_pair(p[i], i);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", s + i);
    ss.insert(make_pair(s[i], i));
  }
  sort(pp + 1, pp + n + 1);
  for (int i = n; i >= 1; --i) {
    int x = pp[i].first;
    int l = x;
    int r = x;
    while (l <= 1e9) {
      set<pair<int, int> >::iterator it = ss.lower_bound(make_pair(l, 0));
      if (it != ss.end() && it->first <= r) {
        b[pp[i].second] = it->second;
        ss.erase(it);
        break;
      }
      if (l == 1) {
        l = 2;
        r = 2;
      } else {
        l += l - 1;
        r += r;
      }
    }
  }
  int c = 0;
  int u = 0;
  for (int i = 1; i <= n; ++i) {
    if (b[i]) {
      ++c;
      a[b[i]] = get(s[b[i]], p[i]);
      u += a[b[i]];
    }
  }
  printf("%d %d\n", c, u);
  for (int i = 1; i <= m; ++i) {
    printf("%d%c", a[i], " \n"[i == m]);
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d%c", b[i], " \n"[i == n]);
  }
  return 0;
}
