#include <bits/stdc++.h>
using namespace std;
const int N = 100;
const int oo = 1000;
int v[6000000];
struct node {
  int value, cou, pos;
  node(int _v, int _c, int _p) : value(_v), cou(_c), pos(_p){};
  bool operator<(const node &other) const {
    if (value == other.value) return cou < other.cou;
    return value > other.value;
  }
};
struct coor {
  int val, pos;
  bool operator<(const coor &other) const { return val > other.val; }
};
coor a[200009];
vector<node> b;
int n, m;
int cnt, need;
int dd[200009], choose[200009];
bool mark[200009];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &a[i].val);
    a[i].pos = i;
  }
  for (int i = 1; i <= m; i++) {
    int x;
    scanf("%d", &x);
    int cnt = 0;
    while (x) {
      b.push_back(node(x, cnt, i));
      if (x == 1) break;
      cnt++;
      x = (x + 1) / 2;
    }
  }
  sort(b.begin(), b.end());
  sort(a + 1, a + n + 1);
  int j = 0;
  for (int i = 1; i <= n; i++) {
    while (a[i].val < b[j].value) j++;
    while (1) {
      if (a[i].val != b[j].value) break;
      if (mark[b[j].pos]) {
        j++;
        continue;
      }
      choose[a[i].pos] = b[j].pos;
      dd[b[j].pos] = b[j].cou;
      mark[b[j].pos] = 1;
      cnt++;
      need += b[j].cou;
      break;
    }
  }
  printf("%d %d\n", cnt, need);
  for (int i = 1; i <= m; i++) printf("%d ", dd[i]);
  printf("\n");
  for (int i = 1; i <= n; i++) printf("%d ", choose[i]);
}
