#include <bits/stdc++.h>
using namespace std;
int main() {
  unordered_map<long long int, vector<long long int> > m1;
  long long int n, m;
  cin >> n >> m;
  vector<long long int> p;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    p.push_back(x);
    m1[x].push_back(i);
  }
  vector<long long int> s;
  map<long long int, vector<long long int> > m2;
  for (long long int i = 0; i < m; i++) {
    long long int x;
    cin >> x;
    s.push_back(x);
    m2[x].push_back(i);
  }
  long long int ad = 0, comp = 0;
  vector<long long int> adapters(s.size(), 0);
  vector<long long int> socket(p.size(), 0);
  for (auto it = m2.begin(); it != m2.end(); it++) {
    long long int adtemp = 0, sp = it->first;
    while (it->second.size()) {
      if (m1.find(sp) != m1.end() && m1[sp].size() > 0) {
        comp++;
        long long int h = m1[sp].size();
        long long int g = it->second.size();
        socket[m1[sp][h - 1]] = it->second[g - 1] + 1;
        m1[sp].pop_back();
        ad += adtemp;
        adapters[it->second[g - 1]] = adtemp;
        it->second.pop_back();
        continue;
      }
      if (sp == 1) {
        break;
      }
      adtemp++;
      sp = (sp + 1) / 2;
    }
  }
  cout << comp << " " << ad << "\n";
  for (long long int i = 0; i < adapters.size(); i++) {
    cout << adapters[i] << " ";
  }
  cout << "\n";
  for (long long int i = 0; i < socket.size(); i++) {
    cout << socket[i] << " ";
  }
  return 0;
}
