#include <bits/stdc++.h>
using namespace std;
void file() {}
const int dd = (int)2e5 + 7;
const int INF = (int)1e9 + 7;
int A[dd], B[dd], ANS[dd], ans[dd];
int main() {
  file();
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &B[i]);
  }
  set<pair<int, int> > Sa, Sb;
  for (int i = 0; i < n; ++i) {
    Sa.insert({A[i], i});
  }
  for (int i = 0; i < m; ++i) {
    Sb.insert({B[i], i});
  }
  int k = 0, C = 0, U = 0;
  vector<pair<int, int> > D;
  while ((int)Sb.size()) {
    for (auto it : Sb) {
      auto it2 = Sa.lower_bound({it.first, 0});
      if (it2 == Sa.end()) {
        break;
      }
      if (it2->first == it.first) {
        ANS[it2->second] = it.second + 1;
        ++C;
        U += k;
        ans[it.second] = k;
        D.push_back(it);
        Sa.erase(it2);
      }
    }
    for (auto it : D) {
      Sb.erase(it);
    }
    D = vector<pair<int, int> >(0);
    for (auto it : Sb) {
      pair<int, int> nw = {(it.first + 1) / 2, it.second};
      if (nw.first != it.first) {
        D.push_back(nw);
      }
    }
    Sb.clear();
    for (auto it : D) {
      Sb.insert(it);
    }
    D = vector<pair<int, int> >(0);
    ++k;
  }
  printf("%d %d\n", C, U);
  for (int i = 0; i < m; ++i) {
    printf("%d ", ans[i]);
  }
  puts("");
  for (int i = 0; i < n; ++i) {
    printf("%d ", ANS[i]);
  }
  return 0;
}
