#include <bits/stdc++.h>
using namespace std;
map<int, vector<int> > ID;
pair<int, int> pr[200010];
int sum[200010], match[200010];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int x;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    ID[x].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &pr[i].first);
    pr[i].second = i;
  }
  sort(pr, pr + m);
  int c = 0, u = 0;
  for (int i = 0; i < m; i++) {
    x = pr[i].first;
    int j = 0;
    while (x) {
      if (ID.count(x)) {
        int id = ID[x].back();
        ID[x].pop_back();
        if (ID[x].empty()) ID.erase(x);
        match[id] = pr[i].second + 1;
        c++;
        u += j;
        sum[pr[i].second] = j;
        break;
      }
      if (x == 1) break;
      j++;
      x = (x - 1) / 2 + 1;
    }
  }
  printf("%d %d\n", c, u);
  for (int i = 0; i < m; i++) {
    printf("%d ", sum[i]);
  }
  puts("");
  for (int i = 0; i < n; i++) {
    printf("%d ", match[i]);
  }
  puts("");
  return 0;
}
