#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = 2e5 + 100;
int a[N], b[N];
vector<pair<int, int> > v;
vector<int> f[N];
map<int, int> id;
map<int, int> nxt, st;
int tot;
int nd[N], ans[N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    if (!id[a[i]]) id[a[i]] = ++tot;
    f[id[a[i]]].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", b + i);
    v.emplace_back(b[i], i);
  }
  sort(v.begin(), v.end());
  int c = 0, u = 0;
  for (int i = 0; i < m; i++) {
    int x = v[i].first, need = 0;
    if (nxt[x]) need = st[x], x = nxt[x];
    while (x > 1 && !f[id[x]].size()) x = x + 1 >> 1, need++;
    if (f[id[x]].size()) {
      c++, u += need, nd[v[i].second] = need;
      int g = f[id[x]].back();
      ans[g] = v[i].second + 1;
      f[id[x]].pop_back();
    }
  }
  cout << c << " " << u << endl;
  for (int i = 0; i < m; i++) {
    printf("%d ", nd[i]);
  }
  cout << endl;
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
