#include <bits/stdc++.h>
using namespace std;
int n, m, ansP[2000042], ansS[2000042], ansSum, ansPP;
pair<int, int> p[2000042];
struct s {
  int ind, d, ss;
  s(int ind_ = 0, int d_ = 0, int ss_ = 0) {
    ind = ind_;
    d = d_ + 1;
    ss = (ss_ + 1) / 2;
  }
  bool operator<(const s& other) const {
    return ss == other.ss ? d > other.d : ss < other.ss;
  }
} arr[2000042];
priority_queue<s> q;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p, p + n);
  reverse(p, p + n);
  for (int i = 0; i < m; i++) {
    cin >> arr[i].ss;
    arr[i].ind = i;
    arr[i].d = 0;
    q.push(arr[i]);
  }
  int i = 0;
  for (; i < n && !q.empty();) {
    if (p[i].first > q.top().ss) {
      i++;
    } else if (p[i].first == q.top().ss) {
      ansPP++;
      ansSum += q.top().d;
      ansP[p[i].second] = q.top().ind + 1;
      ansS[q.top().ind] = q.top().d;
      q.pop();
      i++;
    } else {
      s crr = s(q.top().ind, q.top().d, q.top().ss);
      q.pop();
      q.push(crr);
    }
  }
  cout << ansPP << " " << ansSum << "\n";
  for (int i = 0; i < m; i++) {
    cout << ansS[i] << " ";
  }
  cout << "\n";
  for (int i = 0; i < n; i++) {
    cout << ansP[i] << " ";
  }
  cout << "\n";
  return 0;
}
