#include <bits/stdc++.h>
using namespace std;
long long cp[200005], add[200005];
map<long long, vector<long long> > mp;
pair<long long, long long> socket[200005], power[200005];
int main() {
  long long i, j, k;
  long long n, m;
  long long cnt, mx = 0, adpter = 0;
  cin >> n >> m;
  for (i = 0; i < n; ++i) {
    scanf("%I64d", &power[i].first);
    power[i].second = i;
    mp[power[i].first].push_back(i);
  }
  for (i = 0; i < m; ++i) {
    scanf("%I64d", &socket[i].first);
    socket[i].second = i;
  }
  sort(socket, socket + m);
  for (i = 0; i < m; ++i) {
    cnt = 0;
    while (1) {
      if (!mp[socket[i].first].empty()) {
        add[socket[i].second] = cnt;
        mx++;
        adpter += cnt;
        cp[mp[socket[i].first].back()] = socket[i].second + 1;
        mp[socket[i].first].pop_back();
        break;
      }
      if (socket[i].first == 1) break;
      cnt++;
      if (socket[i].first % 2) socket[i].first++;
      socket[i].first = socket[i].first / 2;
    }
  }
  cout << mx << " " << adpter << endl;
  for (i = 0; i < m; ++i) printf("%I64d ", add[i]);
  cout << endl;
  for (i = 0; i < n; ++i) printf("%I64d ", cp[i]);
  cout << endl;
}
