#include <bits/stdc++.h>
using namespace std;
int ans1[200001];
int ans2[200001];
pair<int, int> a[200001];
int main() {
  memset(ans1, -1, sizeof ans1);
  int n, m;
  scanf("%d%d", &n, &m);
  multiset<pair<int, int>> s;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    s.insert({x, i});
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  int ma, mi;
  ma = 0;
  mi = 0;
  sort(a, a + m);
  for (int i = 0; i < m; i++) {
    if (s.size() == 0) continue;
    int x = a[i].first;
    int idx = a[i].second;
    int cnt = 0;
    bool flag = false;
    while (x > 1) {
      multiset<pair<int, int>>::iterator it = s.lower_bound(make_pair(x, -1));
      if (it == s.end() || it->first != x)
        x = (x + 1) / 2, cnt++;
      else {
        mi += cnt;
        ma++;
        ans1[it->second] = idx;
        s.erase(it);
        flag = true;
        break;
      }
    }
    if (!flag) {
      multiset<pair<int, int>>::iterator it = s.lower_bound(make_pair(x, -1));
      if (it == s.end() || it->first != x) {
      } else {
        mi += cnt;
        ma++;
        ans1[it->second] = idx;
        s.erase(it);
        flag = true;
      }
    }
    ans2[idx] = flag ? cnt : 0;
  }
  printf("%d %d\n", ma, mi);
  for (int i = 0; i < m; i++) printf("%d ", ans2[i]);
  printf("\n");
  for (int i = 0; i < n; i++) printf("%d ", ans1[i] + 1);
  return 0;
}
