#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int mod = 1000000007;
const double pi = acos(-1.0);
inline void gn(long long& x) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  c == '-' ? (sg = -1, x = 0) : (x = c - '0');
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= sg;
}
inline void gn(int& x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(unsigned long long& x) {
  long long t;
  gn(t);
  x = t;
}
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
long long powmod(long long a, long long x, long long mod) {
  long long t = 1ll;
  while (x) {
    if (x & 1) t = t * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return t;
}
const int maxn = 222222;
pair<int, int> pp[maxn];
map<int, int> need;
int fix[maxn];
map<int, vector<int> > hasid;
map<int, int> has;
int val[maxn];
int main() {
  int n, m;
  int totmatch = 0, totfix = 0;
  memset((fix), 0, sizeof(fix));
  gn(n);
  gn(m);
  for (int i = (1); i <= (n); i++) {
    int x;
    gn(x);
    need[x]++;
    val[i] = x;
  }
  for (int i = (1); i <= (m); i++) {
    int vv;
    gn(vv);
    pp[i].first = vv;
    pp[i].second = i;
  }
  sort(pp + 1, pp + 1 + m);
  for (int i = (1); i <= (m); i++) {
    int p = pp[i].first;
    p = p * 2;
    int tmp = -1;
    while (true) {
      if (p == 1) break;
      p = (p + 1) / 2;
      tmp++;
      if (need.count(p) && has[p] < need[p]) break;
    }
    if (need.count(p) && has[p] < need[p]) {
      totfix += tmp;
      fix[pp[i].second] = tmp;
      hasid[p].push_back(pp[i].second);
      totmatch++;
      has[p]++;
    }
  }
  printf("%d %d\n", totmatch, totfix);
  for (int i = (1); i <= (m); i++) printf("%d ", fix[i]);
  puts("");
  for (int i = (1); i <= (n); i++) {
    if (!need.count(val[i]))
      printf("0 ");
    else {
      if (hasid[val[i]].size() > 0) {
        printf("%d ", hasid[val[i]].back());
        hasid[val[i]].pop_back();
      } else {
        printf("%d ", 0);
      }
    }
  }
  puts("");
  return 0;
}
