#include <bits/stdc++.h>
using namespace std;
struct computer {
  int v, i;
  computer(int _v = 0, int _i = 0) : v(_v), i(_i) {}
  bool operator<(const computer& C) const { return v < C.v; }
};
struct socket {
  int v, i, c;
  socket(int _v = 0, int _i = 0) : v(_v), i(_i), c(0) {}
  bool operator<(const socket& S) const { return v < S.v; }
  void operator()() {
    c++;
    v = (v + 1) >> 1;
  }
};
int main() {
  int n, m, ans = 0, cnt = 0;
  scanf("%d%d", &n, &m);
  multiset<computer> C;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    C.insert(computer(x, i));
  }
  vector<socket> S(m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &S[i].v);
    S[i].i = i;
  }
  sort(S.begin(), S.end());
  vector<int> a(n, 0), b(m, 0);
  for (int i = 0; !C.empty() && i < m; i++) {
    for (; S[i].v >= C.begin()->v; S[i]()) {
      auto it = C.find(S[i].v);
      if (it != C.end()) {
        ans++;
        cnt += S[i].c;
        b[S[i].i] = S[i].c;
        a[it->i] = S[i].i + 1;
        C.erase(it);
        break;
      }
    }
  }
  printf("%d %d\n", ans, cnt);
  for (int i = 0; i < m; i++) printf(i == m - 1 ? "%d\n" : "%d ", b[i]);
  for (int i = 0; i < n; i++) printf(i == n - 1 ? "%d\n" : "%d ", a[i]);
}
