#include <bits/stdc++.h>
using namespace std;
struct data {
  int val, cs;
} b[200010];
int a[200010], m, g[200010], n;
queue<int> A[200010];
set<int> s;
map<int, int> ma, maa;
bool cmp(data a, data b) { return a.val < b.val; }
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = (1), _b = (n); i <= _b; i++) cin >> a[i];
  for (int i = (1), _b = (m); i <= _b; i++) {
    cin >> b[i].val;
    b[i].cs = i;
  }
  for (int i = (1), _b = (n); i <= _b; i++) {
    s.insert(a[i]);
    ma[a[i]]++;
  }
  int N = 0;
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) maa[*it] = ++N;
  sort(b + 1, b + m + 1, cmp);
  int res = 0;
  int soc = 0;
  for (int i = (1), _b = (m); i <= _b; i++) {
    int k = b[i].val;
    int z = -1;
    while (k) {
      z++;
      if (s.count(k)) {
        ma[k]--;
        if (ma[k] == 0) s.erase(k);
        A[maa[k]].push(b[i].cs);
        soc += z;
        g[b[i].cs] = z;
        res++;
        break;
      }
      if (k == 1) break;
      k = k / 2 + (k % 2);
    }
  }
  printf("%d %d\n", res, soc);
  for (int i = (1), _b = (m); i <= _b; i++) printf("%d ", g[i]);
  printf("\n");
  for (int i = (1), _b = (n); i <= _b; i++) {
    int w = maa[a[i]];
    if (!A[w].empty()) {
      printf("%d ", A[w].front());
      A[w].pop();
    } else
      printf("0 ");
  }
  return 0;
}
