#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> ar, sht;
int used[202020];
int r[202020];
map<int, vector<int>> occ;
int rn, rm;
int main() {
  rn = 0, rm = 0;
  int n, m;
  scanf("%d %d", &n, &m);
  int t;
  for (int ctr1 = 0; ctr1 < n; ctr1++) {
    scanf("%d", &t);
    occ[t].push_back(ctr1);
  }
  for (int ctr2 = 0; ctr2 < m; ctr2++) {
    scanf("%d", &t);
    sht.push_back({t, ctr2});
  }
  sort(sht.begin(), sht.end());
  for (int ctr2 = 0; ctr2 < m; ctr2++) {
    t = sht[ctr2].first;
    int l = 0;
    while (1) {
      if (occ.count(t) && occ[t].size() > 0) {
        int y = occ[t].back();
        used[sht[ctr2].second] = l;
        r[y] = sht[ctr2].second + 1;
        rn++;
        rm += l;
        occ[t].pop_back();
        break;
      }
      if (t == (t + 1) / 2) break;
      t = (t + 1) / 2;
      l++;
    }
  }
  printf("%d %d\n", rn, rm);
  for (int ctr1 = 0; ctr1 < m; ctr1++) printf("%d ", used[ctr1]);
  printf("\n");
  for (int ctr1 = 0; ctr1 < n; ctr1++) printf("%d ", r[ctr1]);
  return 0;
}
