#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  cin >> n >> m;
  pair<int, int> b[m];
  multiset<pair<int, int> > a;
  for (int i = 0; i < n; i++) {
    pair<int, int> t;
    scanf("%d", &t.first);
    t.second = i;
    a.insert(t);
  }
  for (int j = 0; j < m; j++) {
    scanf("%d", &b[j].first);
    b[j].second = j;
  }
  int res[m];
  memset(res, 0, sizeof(res));
  int res2[n];
  memset(res2, 0, sizeof(res2));
  sort(b, b + m);
  long long ans = 0, ans2 = 0;
  for (int i = 0; i < m; i++) {
    int y;
    y = b[i].second;
    int p = b[i].first;
    p = p * 2;
    int G = 0;
    while (p >= 1) {
      int temp = p;
      p = p / 2;
      if (temp % 2 == 1) {
        p++;
      }
      if (p == temp) break;
      multiset<pair<int, int> >::iterator itr;
      itr = a.lower_bound(make_pair(p, -1));
      if (itr != a.end()) {
        pair<int, int> f = *itr;
        if (f.first == p) {
          res2[f.second] = y + 1;
          res[y] = G;
          ans2++;
          ans += G;
          a.erase(a.find(f));
          break;
        }
      }
      G++;
    }
  }
  cout << ans2 << " " << ans << endl;
  for (int i = 0; i < m; i++) {
    printf("%d ", res[i]);
  }
  cout << endl;
  for (int i = 0; i < n; i++) {
    printf("%d ", res2[i]);
  }
}
