#include <bits/stdc++.h>
struct node {
  int x, y, xh;
  bool friend operator<(const node &a, const node &b) {
    if (a.x == b.x) return a.y > b.y;
    return a.x > b.x;
  }
} p;
int n, m, i, j, a[200010], b[200010], ans1, ans[200010], tmp, k, ans2[200010];
std::set<std::pair<int, int> > se;
std::priority_queue<node> que;
std::set<std::pair<int, int> >::iterator ii;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    scanf("%d", a + i), se.insert(std::make_pair(a[i], i));
  for (i = 1; i <= m; i++) scanf("%d", b + i), que.push((node){0, b[i], i});
  while (!se.empty() && !que.empty()) {
    p = que.top();
    que.pop();
    ii = se.upper_bound(std::make_pair(p.y, 0));
    if (ii != se.end()) {
      if ((*ii).first == p.y) {
        ans[(*ii).second] = p.xh;
        ans2[p.xh] = p.x;
        se.erase(ii);
        ans1 += p.x;
      } else if (p.y > 1)
        que.push((node){p.x + 1, (p.y >> 1) + (p.y & 1), p.xh});
    } else if (p.y > 1)
      que.push((node){p.x + 1, (p.y >> 1) + (p.y & 1), p.xh});
  }
  printf("%d %d\n", n - se.size(), ans1);
  for (i = 1; i <= m; i++) printf("%d ", ans2[i]);
  puts("");
  for (i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
