#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, pwr, c = 0, u = 0, swr;
  multiset<pair<int, int>> p;
  vector<pair<int, int>> s;
  int a[200002] = {0};
  int b[200002] = {0};
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> pwr;
    p.insert({pwr, i});
  }
  for (int i = 1; i <= m; ++i) {
    cin >> swr;
    s.push_back({swr, i});
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < m; ++i) {
    int ps = s[i].first;
    int ia = s[i].second;
    int hop = 0;
    while (ps) {
      auto f = p.lower_bound({ps, numeric_limits<int>::min()});
      if (f != p.end() && (*f).first == ps) {
        int ib = (*f).second;
        p.erase(f);
        u += hop;
        a[ia] = hop;
        b[ib] = ia;
        c++;
        break;
      }
      if (ps == 1) break;
      ps = (ps + 1) / 2;
      hop++;
    }
  }
  cout << c << " " << u << endl;
  for (int i = 1; i <= m; ++i) {
    cout << a[i] << " ";
  }
  cout << endl;
  for (int i = 1; i <= n; ++i) {
    cout << b[i] << " ";
  }
  cout << endl;
  return 0;
}
