#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return (a.second).first < (b.second).first;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  pair<int, pair<int, int> > a;
  priority_queue<pair<int, pair<int, int> > > q;
  int soc[200000], comp[200000], x, n, m;
  pair<int, int> p[200001];
  memset(soc, 0, sizeof(soc));
  memset(comp, 0, sizeof(comp));
  cin >> n >> m;
  for (int i = 0; i < (n); ++i) {
    cin >> x;
    p[i] = make_pair(x, i + 1);
  }
  sort(p, p + n);
  for (int i = 0; i < (m); ++i) {
    cin >> x;
    q.push(make_pair(x, make_pair(0, i + 1)));
  }
  int j = n - 1, adap = 0, ans = 0;
  while (j >= 0 && !q.empty()) {
    a = q.top();
    if (a.first == p[j].first) {
      soc[(a.second).second - 1] = (-1) * (a.second).first;
      adap -= (a.second).first;
      comp[p[j].second - 1] = (a.second).second;
      j--;
      ans++;
      q.pop();
    } else if (a.first > p[j].first) {
      q.pop();
      (a.second).first -= 1;
      a.first = (a.first + 1) / 2;
      q.push(a);
    } else {
      j--;
    }
  }
  cout << ans << " " << adap << endl;
  for (int i = 0; i < (m); ++i) cout << soc[i] << " ";
  cout << "\n";
  for (int i = 0; i < (n); ++i) cout << comp[i] << " ";
  return 0;
}
