#include <bits/stdc++.h>
using namespace std;
struct PC {
  int power;
  int idx;
  friend bool operator<(const PC& a, const PC& b) { return a.power < b.power; }
};
int s[200010];
bool vis[200010];
int a[200010];
int b[200010];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  multiset<PC> pc;
  int p;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p);
    pc.insert({p, i});
  }
  for (int i = 1; i <= m; i++) scanf("%d", s + i);
  int c = 0, u = 0;
  for (int i = 0; i < 31; i++) {
    for (int j = 1; j <= m; j++) {
      if (!vis[j]) {
        multiset<PC>::iterator it = pc.find({s[j], 0});
        if (it != pc.end()) {
          b[it->idx] = j;
          vis[j] = true;
          pc.erase(it);
          c++;
          u += a[j];
        }
      }
    }
    for (int j = 1; j <= m; j++)
      if (!vis[j]) a[j]++, s[j] = (s[j] + 1) / 2;
  }
  printf("%d %d\n", c, u);
  for (int i = 1; i <= m; i++) printf("%d ", vis[i] ? a[i] : 0);
  puts("");
  for (int i = 1; i <= n; i++) printf("%d ", b[i]);
  return 0;
}
