#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int MOD = (int)1e9 + 7;
const long long LINF = (long long)1e15 + 7;
const int INF = (int)1e9 + 7;
const double eps = 1e-7;
const int MAXN = (int)2e5 + 107;
const int MAXX = (int)1e2 + 7;
const double pi = acos(-1);
int p[MAXN];
int s[MAXN];
int kp[MAXN];
int used[MAXN];
int ans[MAXN];
struct rz {
  int k, r, v;
  rz(int _k, int _r, int _v) {
    r = _r;
    k = _k;
    v = _v;
  }
  bool operator<(const rz &b) const {
    return k < b.k || k == b.k && r < b.r || k == b.k && r == b.r && v < b.v;
  }
};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &s[i]);
  }
  vector<rz> a;
  multimap<int, int> mp;
  int kol = 0;
  int ansk = 0;
  for (int i = 0; i < n; ++i) {
    mp.insert({p[i], i});
    ans[i] = -1;
  }
  for (int i = 0; i < m; ++i) {
    int c = s[i];
    int k = 0;
    while (c > 1) {
      a.push_back({k, i, c});
      c = ceil((double)c / 2);
      k++;
    }
    a.push_back({k, i, c});
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < a.size(); ++i) {
    int v = a[i].v;
    int k = a[i].k;
    int r = a[i].r;
    if (used[r]) {
      continue;
    }
    auto cmp = mp.find(v);
    if (cmp != mp.end()) {
      kol += k;
      used[r] = 1;
      ans[cmp->second] = r;
      kp[r] = k;
      ansk++;
      mp.erase(cmp);
    } else {
      continue;
    }
  }
  printf("%d %d\n", ansk, kol);
  for (int i = 0; i < m; ++i) {
    printf("%d ", kp[i]);
  }
  cout << "\n";
  for (int i = 0; i < n; ++i) {
    printf("%d ", ans[i] + 1);
  }
  return 0;
}
