#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  multiset<int> p;
  map<int, vector<int> > id;
  pair<int, int> s[m];
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    p.insert(x);
    id[x].push_back(i);
  }
  for (int j = 0; j < m; j++) {
    cin >> s[j].first;
    s[j].second = j;
  }
  sort(s, s + m);
  int a[m];
  int b[n];
  memset(b, 0, sizeof(b));
  memset(a, 0, sizeof(a));
  int cnt = 0;
  int res = 0;
  for (int i = 0; i < m && !p.empty(); i++) {
    int t = 0;
    multiset<int>::iterator it;
    while (s[i].first > 1 && id[s[i].first].empty()) {
      s[i].first = (s[i].first + 1) / 2;
      t++;
    }
    if (!id[s[i].first].empty()) {
      res++;
      cnt += t;
      a[s[i].second] = t;
      b[id[s[i].first].back()] = s[i].second + 1;
      id[s[i].first].pop_back();
    }
  }
  cout << res << " " << cnt << endl;
  for (int i = 0; i < m; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  for (int i = 0; i < n; i++) cout << b[i] << " ";
  return 0;
}
