#include <bits/stdc++.h>
using namespace std;
int n, m, first, i, t, tmp, sum1, sum2, ans1[200001], ans2[200001];
pair<int, int> a[200001];
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &first);
    s.insert(make_pair(first, i));
  }
  for (i = 1; i <= m; i++) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a + 1, a + m + 1);
  for (i = 1; i <= m; i++)
    for (t = a[i].first, tmp = 0;; t = (t + 1) >> 1, tmp++) {
      it = s.lower_bound(make_pair(t, 0));
      if (it != s.end() && it->first == t) {
        sum1++;
        sum2 += tmp;
        ans1[a[i].second] = tmp;
        ans2[it->second] = a[i].second;
        s.erase(it);
        break;
      }
      if (t == 1) break;
    }
  printf("%d %d\n", sum1, sum2);
  for (i = 1; i < m; i++) printf("%d ", ans1[i]);
  printf("%d\n", ans1[m]);
  for (i = 1; i < n; i++) printf("%d ", ans2[i]);
  printf("%d\n", ans2[n]);
  return 0;
}
