#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;
struct node {
  int id, num;
  node() {}
  node(int nn, int ii) : num(nn), id(ii) {}
  bool operator<(const node& other) const {
    if (num != other.num) return num < other.num;
    return id < other.id;
  }
} a[maxn], b[maxn];
int ans_a[maxn];
int ans_b[maxn];
map<int, int> ma;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].num);
    a[i].id = i;
    ma[a[i].num]++;
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i].num);
    b[i].id = i;
  }
  sort(b + 1, b + 1 + m);
  int c = 0, u = 0;
  for (int i = 1; i <= m; i++) {
    int& val = b[i].num;
    for (int cnt = 0; cnt < 31; cnt++) {
      if (ma[val]) {
        int pos = lower_bound(a + 1, a + 1 + n, node(val, 0)) - a + ma[val] - 1;
        if (a[pos].num == val && ans_b[a[pos].id] == 0) {
          ma[val]--;
          ans_b[a[pos].id] = b[i].id;
          ans_a[b[i].id] = cnt;
          u += cnt;
          c++;
          break;
        }
      }
      val = (val + 1) / 2;
    }
  }
  printf("%d %d\n", c, u);
  for (int i = 1; i <= m; i++) {
    printf("%d%c", ans_a[i], i == m ? '\n' : ' ');
  }
  for (int i = 1; i <= n; i++) {
    printf("%d%c", ans_b[i], i == n ? '\n' : ' ');
  }
  return 0;
}
