#include <bits/stdc++.h>
using namespace std;
int n, m;
int d[223456];
int t[223456];
int res[223456];
int add[223456];
int ros[223456];
int main() {
  cin >> n >> m;
  map<int, vector<int> > comp;
  for (int i = 0; i < n; i++) {
    scanf("%d", &d[i]);
    comp[d[i]].push_back(i);
    add[i] = -1;
  }
  set<pair<int, pair<int, int> > > all;
  for (int i = 0; i < m; i++) {
    scanf("%d", &t[i]);
    all.insert(make_pair(t[i], make_pair(0, i)));
  }
  int ans = 0;
  int tot = 0;
  while (!all.empty()) {
    int x = (*all.rbegin()).first;
    int id = (*all.rbegin()).second.second;
    all.erase(--all.end());
    if (comp.count(x) && !comp[x].empty()) {
      int who = comp[x].back();
      comp[x].pop_back();
      add[who] = id;
      res[id] = ros[id];
      tot += res[id];
      ans++;
    } else if ((x + 1) / 2 != x) {
      ros[id]++;
      all.insert(make_pair((x + 1) / 2, make_pair(-ros[id], id)));
    }
  }
  cout << ans << ' ' << tot << endl;
  for (int i = 0; i < m; i++) {
    printf("%d ", res[i]);
  }
  cout << endl;
  for (int i = 0; i < n; i++) {
    printf("%d ", add[i] + 1);
  }
  return 0;
}
