#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 5;
unordered_map<int, vector<int>> cnt;
bool done[N];
int arr[N], ansa[N], ansb[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt[x].push_back(i);
  }
  for (int i = 0; i < m; i++) cin >> arr[i];
  for (int _ = 0; _ < 1000; _++) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      if (done[i]) continue;
      if (arr[i] != 1) flag = false;
      auto it = cnt.find(arr[i]);
      if (it != cnt.end()) {
        ansa[i] = _;
        ansb[it->second.back()] = i + 1;
        it->second.pop_back();
        if (it->second.empty()) cnt.erase(it);
        done[i] = true;
      }
      arr[i] = (arr[i] + 1) / 2;
    }
    if (flag) break;
  }
  long long suma = 0, sumb = 0;
  for (int i = 0; i < m; i++) suma += ansa[i];
  for (int i = 0; i < n; i++) sumb += (ansb[i] != 0);
  cout << sumb << ' ' << suma << '\n';
  for (int i = 0; i < m; i++) cout << ansa[i] << " \n"[i == m - 1];
  for (int i = 0; i < n; i++) cout << ansb[i] << " \n"[i == n - 1];
  return 0;
}
