#include <bits/stdc++.h>
using namespace std;
int n, m, top, al, ans;
int A[201000], B[201000], cnt[201000], val[201000], mark[201000];
int nex[201000], fst[201000];
int q[201000];
map<int, int> mp;
bool pmc(int a, int b) { return (B[a] < B[b]); }
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
    mp[A[i]] = 1;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &B[i]);
    q[i] = i;
  }
  for (auto i = mp.begin(); i != mp.end(); i++) i->second = ++top;
  for (int i = 1; i <= n; i++) {
    int t = mp[A[i]];
    nex[i] = fst[t];
    fst[t] = i;
  }
  sort(q + 1, q + m + 1, pmc);
  for (int i = 1; i <= m; i++) {
    int u = q[i];
    for (; !mp[B[u]] && B[u] != 1; B[u] = (B[u] + 1) >> 1) cnt[u]++;
    int t;
    if ((t = mp[B[u]])) {
      int v = fst[t];
      mark[v] = u;
      al++;
      ans += cnt[u];
      fst[t] = nex[fst[t]];
      if (!fst[t]) mp[B[u]] = 0;
    } else
      cnt[u] = 0;
  }
  printf("%d %d\n", al, ans);
  for (int i = 1; i <= m; i++) printf("%d ", cnt[i]);
  putchar('\n');
  for (int i = 1; i <= n; i++) printf("%d ", mark[i]);
  return 0;
}
