#include <bits/stdc++.h>
using namespace std;
map<int, vector<int> > M;
pair<int, int> sock[200001];
int fans[200001];
int num[200001];
int main() {
  ios_base::sync_with_stdio(0);
  int i, n, m, x;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> x;
    M[x].push_back(i);
  }
  for (i = 1; i <= m; i++) {
    cin >> x;
    sock[i] = {x, i};
  }
  sort(sock + 1, sock + 1 + m);
  int ans = 0;
  int total = 0;
  for (i = 1; i <= m; i++) {
    int temp1 = sock[i].first;
    int temp2 = sock[i].second;
    int adap = 0;
    while (1) {
      if (M[temp1].size()) {
        ans++;
        num[M[temp1].back()] = temp2;
        fans[temp2] = adap;
        M[temp1].pop_back();
        total += adap;
        break;
      }
      if (temp1 == 1) break;
      adap++;
      if (temp1 % 2 == 0) {
        temp1 /= 2;
      } else {
        temp1 /= 2;
        temp1++;
      }
    }
  }
  cout << ans << " " << total << endl;
  for (i = 1; i <= m; i++) {
    cout << fans[i] << " ";
  }
  cout << endl;
  for (i = 1; i <= n; i++) {
    cout << num[i] << " ";
  }
  cout << endl;
  return 0;
}
