#include <bits/stdc++.h>
using namespace std;
struct cc {
  int V, ads, match_com, index;
  cc(){};
  cc(int V, int ads, int match_com, int index)
      : V(V), ads(ads), match_com(match_com), index(index){};
  bool operator<(const cc &a) const {
    return ads > a.ads || (ads == a.ads && V < a.V);
  }
};
struct cm {
  int V, match_soc;
};
cc socs[200005];
cm coms[200005];
priority_queue<cc> que;
multimap<int, int> Map;
multimap<int, int>::iterator it;
int ans_coms, ans_ads;
int main() {
  int com, soc;
  scanf("%d %d", &com, &soc);
  for (int i = 1; i <= com; ++i) {
    scanf("%d", &coms[i].V);
    coms[i].match_soc = 0;
    Map.insert(pair<int, int>(coms[i].V, i));
  }
  for (int i = 1; i <= soc; ++i) {
    scanf("%d", &socs[i].V);
    socs[i].ads = socs[i].match_com = 0;
    socs[i].index = i;
    que.push(socs[i]);
  }
  while (!que.empty()) {
    cc cct = que.top();
    que.pop();
    it = Map.find(cct.V);
    if (it != Map.end()) {
      coms[(*it).second].match_soc = cct.index;
      socs[cct.index].ads = cct.ads;
      ans_coms++;
      ans_ads += cct.ads;
      Map.erase(it);
    } else {
      if (cct.V == 1) continue;
      cct.V = (cct.V + 1) >> 1;
      cct.ads++;
      que.push(cct);
    }
  }
  printf("%d %d\n", ans_coms, ans_ads);
  for (int i = 1; i < soc; ++i) printf("%d ", socs[i].ads);
  printf("%d\n", socs[soc].ads);
  for (int i = 1; i <= com; ++i) printf("%d ", coms[i].match_soc);
  return 0;
}
