#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<pair<int, int> > P(n), S(m);
  vector<int> ansP(n), ansS(m);
  map<int, vector<int> > mp;
  for (int i = 0; i < n; i++)
    scanf("%d", &P[i].first), P[i].second = i, mp[P[i].first].push_back(i);
  for (int i = 0; i < m; i++) scanf("%d", &S[i]), S[i].second = i;
  int sumS = 0, sumP = 0;
  sort(S.begin(), S.end());
  for (int i = 0; i < S.size(); i++) {
    int no = S[i].first;
    int sz = 0;
    while (no) {
      if (mp.count(no) && mp[no].size() > 0) {
        int cur = mp[no][mp[no].size() - 1];
        mp[no].pop_back();
        ansP[cur] = S[i].second + 1;
        ansS[S[i].second] = sz;
        sumP++;
        sumS += sz;
        break;
      }
      if (no == 1) break;
      no = (no + 1) / 2;
      sz++;
    }
  }
  printf("%d %d\n", sumP, sumS);
  for (int i = 0; i < m; i++) printf("%d ", ansS[i]);
  printf("\n");
  for (int i = 0; i < n; i++) printf("%d ", ansP[i]);
}
