#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int n, m;
int pc[MAXN];
int ps[MAXN];
int ans[MAXN];
int butuh[MAXN];
map<int, vector<int> > p;
pair<int, int> sup[MAXN];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &pc[i]);
    p[pc[i]].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &ps[i]);
    sup[i].first = ps[i];
    sup[i].second = i;
  }
  sort(sup + 1, sup + m + 1);
  int c = 0, u = 0;
  for (int i = 1; i <= m; i++) {
    int val = sup[i].first;
    int ambil = -1;
    int kurang = 0;
    int ambilk = -1;
    while (val > 0) {
      if (p[val].size() > 0) {
        ambil = val;
        ambilk = kurang;
        break;
      }
      if (val == 1) break;
      val = (val + 1) / 2;
      kurang++;
    }
    if (ambil == -1) continue;
    c++;
    u += ambilk;
    int size = p[ambil].size();
    int comp = p[ambil][size - 1];
    p[ambil].pop_back();
    butuh[sup[i].second] = ambilk;
    ans[comp] = sup[i].second;
  }
  printf("%d %d\n", c, u);
  for (int i = 1; i <= m; i++) {
    printf("%d ", butuh[i]);
  }
  printf("\n");
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  printf("\n");
}
