#include <bits/stdc++.h>
using namespace std;
int mydiv(int x) {
  if (x == 1) return 0;
  int y = x / 2;
  if (y * 2 != x) y++;
  return y;
}
int main() {
  int n, m;
  cin >> n >> m;
  multiset<int> p;
  multiset<int>::iterator it;
  vector<pair<int, int> > s(m);
  vector<int> answers(m);
  vector<int> companswer(n);
  map<int, vector<int> > indx;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    p.insert(x);
    indx[x].push_back(i);
  }
  int y;
  for (int i = 0; i < m; i++) {
    cin >> y;
    s[i] = make_pair(y, i);
  }
  sort(s.begin(), s.end());
  int count = 0;
  for (int i = 0; i < m; i++) {
    int curcount = 0;
    while (s[i].first != 0) {
      it = p.find(s[i].first);
      if (it != p.end()) {
        p.erase(it);
        count += curcount;
        answers[s[i].second] = curcount;
        companswer[indx[s[i].first][indx[s[i].first].size() - 1]] =
            s[i].second + 1;
        indx[s[i].first].erase(indx[s[i].first].begin() +
                               indx[s[i].first].size() - 1);
        break;
      }
      s[i].first = mydiv(s[i].first);
      curcount++;
    }
  }
  cout << n - p.size() << " " << count << endl;
  for (int i = 0; i < m; i++) cout << answers[i] << " ";
  cout << endl;
  for (int i = 0; i < n; i++) {
    cout << companswer[i] << " ";
  }
  return 0;
}
