#include <bits/stdc++.h>
using namespace std;
int main() {
  unordered_map<int, int> m1;
  int n, m;
  cin >> n >> m;
  unordered_map<int, set<int> > s;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    m1[x] += 1;
    s[x].insert(i + 1);
  }
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    v.push_back(make_pair(x, i + 1));
  }
  sort(v.begin(), v.end());
  int socket[300010], power[300010];
  memset(socket, 0, sizeof(socket));
  memset(power, 0, sizeof(power));
  int tot_com = 0, tot_adap = 0;
  for (int i = 0; i < v.size(); i++) {
    int cur = 0, one_cnt = 0;
    do {
      if (v[i].first == 1) one_cnt = 1;
      if (m1.find(v[i].first) != m1.end() and m1[v[i].first] > 0) {
        socket[v[i].second] = cur;
        m1[v[i].first] -= 1;
        tot_com++;
        tot_adap += cur;
        int num = *(s[v[i].first]).begin();
        power[num] = v[i].second;
        s[v[i].first].erase(s[v[i].first].begin());
        break;
      }
      cur += 1;
      v[i].first = (v[i].first + 1) / 2;
    } while (v[i].first >= 1 and one_cnt == 0);
  }
  cout << tot_com << ' ' << tot_adap << endl;
  for (int i = 1; i <= m; i++) {
    cout << socket[i] << ' ';
  }
  cout << endl;
  for (int i = 1; i <= n; i++) {
    cout << power[i] << ' ';
  }
  cout << endl;
}
