#include <bits/stdc++.h>
using namespace std;
int n, m;
int p[200010];
int s[200010];
int q[200010];
int ans, v;
int e[200010];
int f[200010];
bool comp(const int &a, const int &b) { return p[a] > p[b]; }
struct comp2 {
  bool operator()(const pair<pair<int, int>, int> &a,
                  const pair<pair<int, int>, int> &b) {
    return a.first.first == b.first.first ? a.first.second > b.first.second
                                          : a.first.first < b.first.first;
  }
};
priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> >,
               comp2>
    Q;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(0); i < (int)(n); ++i) {
    scanf("%d", p + i);
    q[i] = i;
  }
  for (int i = (int)(1); i < (int)(m + 1); ++i) {
    scanf("%d", s + i);
    Q.push(make_pair(make_pair(s[i], 0), i));
  }
  sort(q, q + n, comp);
  int w = 0;
  while (!Q.empty()) {
    int x = Q.top().first.first;
    int y = Q.top().first.second;
    int z = Q.top().second;
    Q.pop();
    while (w < n && x < p[q[w]]) ++w;
    if (w >= n) break;
    if (x == p[q[w]]) {
      e[z] = y;
      f[q[w]] = z;
      v += y;
      ++ans;
      ++w;
    } else {
      Q.push(make_pair(make_pair((x + 1) / 2, y + 1), z));
    }
  }
  printf("%d %d\n", ans, v);
  for (int i = (int)(1); i < (int)(m + 1); ++i) {
    printf("%d%c", e[i], i == m ? '\n' : ' ');
  }
  for (int i = (int)(0); i < (int)(n); ++i) {
    printf("%d%c", f[i], i + 1 == n ? '\n' : ' ');
  }
  return 0;
}
