#include <bits/stdc++.h>
using namespace std;
int ex[200005], conn[200005];
bool cmp(pair<int, int> xx, pair<int, int> yy) { return xx.first < yy.first; }
vector<pair<int, int> > pq;
map<int, vector<int> > mp;
vector<int> vc;
int main() {
  int n, m, i, second, k;
  scanf("%d %d", &n, &m);
  pair<int, int> xx;
  for (i = 1; i <= n; i++) {
    scanf("%d", &k);
    mp[k].push_back(i);
  }
  for (i = 1; i <= m; i++) {
    scanf("%d", &k);
    pq.push_back(pair<int, int>(k, i));
  }
  sort(pq.begin(), pq.end());
  int ck = 1, zz;
  long long cnt = 0, sum = 0;
  for (i = 0; i < m; i++) {
    xx = pq[i];
    zz = xx.first;
    int ct = 0;
    while (zz >= 1) {
      if (!mp[zz].empty()) {
        cnt++;
        sum += ct;
        conn[mp[zz].back()] = xx.second;
        mp[zz].pop_back();
        ex[xx.second] = ct;
        break;
      }
      if (zz == 1)
        break;
      else {
        if (zz % 2 == 1) zz++;
        zz /= 2;
        ct++;
      }
    }
  }
  printf("%I64d %I64d\n", cnt, sum);
  for (i = 1; i <= m; i++) printf("%d ", ex[i]);
  printf("\n");
  for (i = 1; i <= n; i++) printf("%d ", conn[i]);
}
