#include <bits/stdc++.h>
using namespace std;
int n, m, con[200005], adap[200005];
vector<pair<int, int> > com;
priority_queue<pair<int, pair<int, int> > > p;
void setup() {
  cin >> n >> m;
  int a;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    com.push_back(make_pair(a, i));
  }
  for (int i = 1; i <= m; i++) {
    cin >> a;
    p.push(make_pair(a, make_pair(0, i)));
  }
}
void xuly() {
  sort(com.begin(), com.end());
  int able = 0, need = 0;
  for (int i = n - 1; i >= 0; i--) {
    while (!p.empty()) {
      int v = p.top().first;
      if (v < com[i].first) break;
      int c = -p.top().second.first;
      int id = p.top().second.second;
      p.pop();
      if (v == com[i].first) {
        con[com[i].second] = id;
        adap[id] = c;
        able++;
        need += c;
        break;
      }
      if (v != 1) p.push(make_pair((v + 1) >> 1, make_pair(-(c + 1), id)));
    }
    if (p.empty()) break;
  }
  cout << able << ' ' << need << '\n';
  for (int i = 1; i <= m; i++) cout << adap[i] << ' ';
  cout << '\n';
  for (int i = 1; i <= n; i++) cout << con[i] << ' ';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}
