#include <bits/stdc++.h>
using namespace std;
struct node {
  int s;
  int index;
} nodes[200005];
bool cmp(node n1, node n2) { return n1.s < n2.s; }
int match[200005], n, m, tem, sum1, use[200005];
long long sum2;
int half(int x) {
  if (x & 1) {
    return x / 2 + 1;
  } else {
    return x / 2;
  }
}
multimap<int, int> mp;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tem);
    mp.insert(make_pair(tem, i));
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &nodes[i].s);
    nodes[i].index = i;
  }
  sort(nodes + 1, nodes + 1 + m, cmp);
  for (int i = 1; i <= m; i++) {
    int x = nodes[i].s, times = 0, flag = 1;
    do {
      multimap<int, int>::iterator it = mp.find(x);
      if (it != mp.end()) {
        match[it->second] = nodes[i].index;
        mp.erase(it);
        sum2 += (long long)times;
        use[nodes[i].index] = times;
        sum1++;
        flag = 0;
        break;
      }
      times++;
      x = half(x);
    } while (x > 1);
    multimap<int, int>::iterator it = mp.find(x);
    if ((it != mp.end()) && (flag)) {
      match[it->second] = nodes[i].index;
      mp.erase(it);
      use[nodes[i].index] = times;
      sum2 += (long long)times;
      sum1++;
    }
  }
  printf("%d %lld\n", sum1, sum2);
  for (int i = 1; i <= m; i++) {
    printf("%d ", use[i]);
  }
  printf("\n");
  for (int i = 1; i <= n; i++) {
    printf("%d ", match[i]);
  }
}
