#include <bits/stdc++.h>
using namespace std;
long long n, m, x = 0, y = 0, aa[200100], bb[200100];
pair<long long, long long> a[200100], b[200100];
bool used[200100] = {0};
int main() {
  memset(aa, -1, sizeof(aa));
  scanf("%lld %lld", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i].first);
    a[i].second = i;
  }
  for (int i = 0; i < m; i++) {
    scanf("%lld", &b[i].first);
    b[i].second = i;
  }
  sort(a, a + n);
  sort(b, b + m);
  int idx;
  for (int i = 0; i < 35; i++) {
    idx = 0;
    for (int j = 0; j < n; j++) {
      if (aa[a[j].second] != -1) continue;
      for (; idx < m; idx++) {
        if (!used[idx] && a[j].first <= b[idx].first) break;
      }
      if (idx < m && !used[idx] && a[j].first == b[idx].first) {
        used[idx] = 1;
        x++;
        y += i;
        aa[a[j].second] = b[idx].second;
        bb[b[idx].second] = i;
      }
    }
    for (int j = 0; j < m; j++) b[j].first = (b[j].first + 1) / 2;
  }
  printf("%lld %lld\n", x, y);
  for (int i = 0; i < m; i++) printf("%lld ", bb[i]);
  printf("\n");
  for (int i = 0; i < n; i++) printf("%lld ", aa[i] + 1);
  return 0;
}
