#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
int n, m;
int c;
long long u;
int a[N], b[N];
map<int, vector<int> > my;
vector<pair<int, int> > V;
void Connect(int val, int id) {
  int many = 0;
  while (val > 0) {
    if (!my[val].empty()) {
      u += many;
      c++;
      a[id] = many;
      b[my[val].back()] = id;
      my[val].pop_back();
      break;
    }
    if (val == 1) break;
    val = (val + 1) >> 1;
    many++;
  }
}
int main() {
  n = in();
  m = in();
  for (int i = 1; i <= n; i++) {
    int x = in();
    my[x].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    int x = in();
    V.push_back(make_pair(x, i));
  }
  sort(V.begin(), V.end());
  c = 0;
  u = 0;
  for (int i = 0; i < m; i++) {
    Connect(V[i].first, V[i].second);
  }
  printf("%d %I64d\n", c, u);
  for (int i = 1; i <= m; i++) {
    printf("%d%c", a[i], (i == m ? '\n' : ' '));
  }
  for (int i = 1; i <= n; i++) {
    printf("%d%c", b[i], (i == n ? '\n' : ' '));
  }
}
