#include <bits/stdc++.h>
using namespace std;
const int size1 = 4e5;
const int INF = 2e9;
int main() {
  int n, m, i, j;
  cin >> n >> m;
  static int a[size1], b[size1];
  vector<pair<int, int> > v, v1;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    v1.push_back({a[i], i});
  }
  for (i = 1; i <= m; i++) {
    cin >> b[i];
    v.push_back({b[i], i});
  }
  sort(v1.begin(), v1.end());
  sort(v.begin(), v.end());
  map<int, vector<int> > map1;
  for (i = 0; i < n; i++) {
    if (map1.count(v1[i].first)) {
      map1[v1[i].first].push_back(v1[i].second);
    } else {
      map1[v1[i].first] = {};
      map1[v1[i].first].push_back(v1[i].second);
    }
  }
  int ans = 0, sum = 0;
  static int used[size1], used1[size1];
  for (i = 0; i < m; i++) {
    int el = v[i].first;
    int num = 0;
    while (true) {
      if (map1.count(el) != 0 && map1[el].size() > 0) {
        ans++;
        sum += num;
        used[map1[el][map1[el].size() - 1]] = v[i].second;
        used1[v[i].second] = num;
        map1[el].resize(map1[el].size() - 1);
        break;
      } else {
        if (el == 1) {
          break;
        }
        el = (el + 1) / 2;
        num++;
      }
    }
  }
  cout << ans << ' ' << sum << endl;
  for (i = 1; i <= m; i++) {
    cout << used1[i] << ' ';
  }
  cout << endl;
  for (i = 1; i <= n; i++) {
    cout << used[i] << ' ';
  }
  return 0;
}
