#include <bits/stdc++.h>
using namespace std;
const int _N = 2e5 + 5;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
int n, m, tmp, a[_N], b[_N];
multiset<pair<int, int>> p, s;
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cout << fixed;
  cout << setprecision(15);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    p.insert(make_pair(tmp, i + 1));
  }
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    s.insert(make_pair(tmp, i + 1));
  }
  for (auto it = s.begin(); it != s.end(); it++) {
    int vol = (it->first);
    int idx = (it->second);
    int cnt = 0;
    while (1) {
      auto itr = p.lower_bound(make_pair(vol, -1));
      if (itr != p.end() && (itr->first) == vol) {
        a[idx] = cnt;
        b[itr->second] = idx;
        p.erase(itr);
        break;
      }
      if (vol == 1) break;
      vol = (vol + 1) / 2;
      cnt++;
    }
  }
  int res = 0;
  for (int i = 1; i <= n; i++) res += (b[i] != 0);
  cout << res << " ";
  res = 0;
  for (int i = 1; i <= m; i++) res += a[i];
  cout << res << '\n';
  for (int i = 1; i <= m; i++) cout << a[i] << " ";
  cout << '\n';
  for (int i = 1; i <= n; i++) cout << b[i] << " ";
  return 0;
}
