#include <bits/stdc++.h>
using namespace std;
const int NM = 2e5 + 10;
int p[NM], s[NM], a[NM], b[NM];
bool used[NM];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  unordered_map<int, vector<int>> mp;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    mp[p[i]].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &s[i]);
  }
  int c = 0, u = 0;
  for (int k = 0; k <= 30; k++) {
    for (int i = 1; i <= m; i++) {
      if (!used[i] && !mp[s[i]].empty()) {
        used[i] = true;
        a[i] = k;
        int idx = mp[s[i]].back();
        mp[s[i]].pop_back();
        b[idx] = i;
        c++, u += k;
      }
    }
    for (int i = 1; i <= m; i++) {
      s[i] = (s[i] + 1) / 2;
    }
  }
  printf("%d %d\n", c, u);
  for (int i = 1; i <= m; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
  for (int i = 1; i <= n; i++) {
    printf("%d ", b[i]);
  }
  printf("\n");
  return 0;
}
