#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > s;
int n, m;
set<pair<int, int> > myset;
set<pair<int, int> >::iterator it;
int a[200005], b[200005];
int main() {
  int i, j;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 0; i < n; i++) {
    scanf("%d", &j);
    myset.insert({j, i});
  }
  for (i = 0; i < m; i++) {
    scanf("%d", &j);
    s.push_back({j, i});
  }
  sort(s.begin(), s.end());
  int c = 0, u = 0;
  for (i = 0; i < s.size(); i++) {
    int val = s[i].first, pos = s[i].second + 1;
    int steps = 0;
    while (1) {
      it = myset.lower_bound({val, -1});
      if (it != myset.end() && (*it).first == val) {
        c++;
        u += steps;
        a[pos] = steps;
        b[(*it).second + 1] = pos;
        myset.erase(it);
        break;
      }
      if (val == 1) break;
      int newval = val / 2;
      if (val % 2) newval++;
      val = newval;
      steps++;
    }
  }
  printf("%d %d\n", c, u);
  for (i = 1; i <= m; i++) printf("%d ", a[i]);
  printf("\n");
  for (i = 1; i <= n; i++) printf("%d ", b[i]);
  return 0;
}
