#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int s[N], p[N], links[N], linkp[N], id[N];
bool cmp(int i, int j) { return s[i] < s[j]; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> all;
  unordered_map<int, vector<int>> ms;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
    ms[p[i]].push_back(i);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &s[i]);
    id[i] = i;
  }
  sort(id + 1, id + 1 + m, cmp);
  int ans0 = 0, ans1 = 0;
  for (int ii = 1; ii <= m; ++ii) {
    int cnt = 0, i = id[ii];
    while (s[i]) {
      if (ms.count(s[i]) && !ms[s[i]].empty()) {
        ans0++;
        ans1 += cnt;
        links[i] = cnt;
        linkp[ms[s[i]].back()] = i;
        ms[s[i]].pop_back();
        break;
      }
      if (s[i] == 1) break;
      s[i] = (s[i] + 1) / 2;
      cnt++;
    }
  }
  printf("%d %d\n", ans0, ans1);
  for (int i = 1; i <= m; ++i) printf("%d ", links[i]);
  puts("");
  for (int i = 1; i <= n; ++i) printf("%d ", linkp[i]);
  puts("");
}
