#include <bits/stdc++.h>
using namespace std;
int n, m;
pair<int, int> p[200200], s[200200];
int per[200200], num[200200], numcomp[200200];
long long U, C;
int bs(int t) {
  int L = 1, R = n + 1;
  while (R - L > 1) {
    int mid = (R + L) / 2;
    if (p[mid].first > t || (p[mid].first == t && num[mid]))
      R = mid;
    else
      L = mid;
  }
  if (p[L].first == t && !num[L]) return L;
  return -1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &p[i].first);
    p[i].second = i;
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &s[i].first);
    s[i].second = i;
  }
  sort(p + 1, p + n + 1);
  sort(s + 1, s + m + 1);
  for (int i = 1; i <= m; ++i) {
    int u = 0, x = s[i].first;
    do {
      int pos = bs(x);
      if (pos > 0) {
        U += 1ll * u;
        C++;
        per[s[i].second] = u;
        num[pos] = s[i].second;
        numcomp[p[pos].second] = s[i].second;
        break;
      }
      if (x == 1) break;
      x = (x + 1) / 2;
      u++;
    } while (true);
  }
  cout << C << " " << U << endl;
  for (int i = 1; i <= m; ++i) {
    cout << per[i] << " ";
  }
  cout << "\n";
  for (int i = 1; i <= n; ++i) {
    cout << numcomp[i] << " ";
  }
  return 0;
}
