#include <bits/stdc++.h>
using namespace std;
struct Soc {
  int no, times, val;
  friend bool operator<(Soc x1, Soc x2) {
    if (x1.val == x2.val) {
      if (x1.times == x2.times)
        return x1.no > x2.no;
      else
        return x1.times > x2.times;
    } else
      return x1.val < x2.val;
  }
} s[200005], temp;
struct Com {
  int no, ans, val;
} c[200005];
priority_queue<Soc> q;
bool cmp1(Com x1, Com x2) {
  if (x1.val == x2.val)
    return x1.no < x2.no;
  else
    return x1.val > x2.val;
}
bool cmp2(Com x1, Com x2) { return x1.no < x2.no; }
int main() {
  int ans1 = 0, ans2 = 0;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i].val);
    c[i].no = i + 1;
    c[i].ans = 0;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &s[i].val);
    s[i].no = i + 1;
    s[i].times = 0;
    q.push(s[i]);
  }
  sort(c, c + n, cmp1);
  for (int i = 0; i < n; i++) {
    if (!q.empty()) {
      while (temp = q.top(), temp.val > c[i].val) {
        q.pop();
        temp.times++;
        temp.val = (temp.val + 1) / 2;
        q.push(temp);
      }
      if (temp.val == c[i].val) {
        ans1++;
        ans2 += temp.times;
        c[i].ans = temp.no;
        s[temp.no - 1].times = temp.times;
        q.pop();
      }
    }
  }
  sort(c, c + n, cmp2);
  cout << ans1 << " " << ans2 << endl;
  for (int i = 0; i < m; i++) printf("%d ", s[i].times);
  printf("\n");
  for (int i = 0; i < n; i++) printf("%d ", c[i].ans);
  printf("\n");
  return 0;
}
