#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, m;
int a[N], b[N], d[N];
pii p[N], s[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  for (int i = 1; i <= m; i++) {
    cin >> s[i].first;
    s[i].second = i;
  }
  sort(p + 1, p + n + 1);
  sort(s + 1, s + m + 1);
  int cur = 0, c = 0;
  ll u = 0;
  bool tag = 0;
  int mm = m;
  while (c < n and mm and s[mm].first >= p[1].first) {
    for (int i = 1; i <= n; i++) {
      if (b[p[i].second]) continue;
      int l = 1, r = mm, pos = 0;
      while (l <= r) {
        int mid = (l + r) >> 1;
        if (s[mid].first < p[i].first)
          l = mid + 1;
        else if (s[mid].first > p[i].first)
          r = mid - 1;
        else if (d[s[mid].second])
          l = mid + 1;
        else
          pos = mid, r = mid - 1;
      }
      if (pos) {
        c++;
        u += cur;
        b[p[i].second] = s[pos].second;
        a[s[pos].second] = cur;
        d[s[pos].second] = 1;
      }
    }
    cur++;
    int tmp = 0;
    for (int i = 1; i <= mm; i++) {
      if (d[s[i].second]) continue;
      s[++tmp] = make_pair((s[i].first + 1) >> 1, s[i].second);
    }
    mm = tmp;
    if (s[mm].first == 1 and tag) break;
    if (s[mm].first == 1) tag = 1;
  }
  cout << c << ' ' << u << '\n';
  for (int i = 1; i <= m; i++) cout << a[i] << " \n"[i == m];
  for (int i = 1; i <= n; i++) cout << b[i] << " \n"[i == n];
  return 0;
}
