#include <bits/stdc++.h>
using namespace std;
int N, M, aux;
set<pair<int, int> >::iterator it;
set<pair<int, int> > S;
vector<pair<int, int> > give;
int used[200005], plug[200005];
int main() {
  cin >> N >> M;
  give.resize(M);
  memset(used, 0, sizeof(used));
  memset(plug, 0, sizeof(plug));
  for (long long i = (0); i < (N); i++) {
    cin >> aux;
    S.insert(pair<int, int>(aux, i));
  }
  for (long long i = (0); i < (M); i++) {
    cin >> give[i].first;
    give[i].second = i + 1;
  }
  int a = 0, b = 0;
  sort((give).begin(), (give).end());
  for (long long i = (0); i < (give.size()); i++) {
    aux = give[i].first;
    int cont = 0;
    while (1) {
      it = S.lower_bound(pair<int, int>(aux, -1));
      if (it != S.end() and (*it).first == aux) {
        a++;
        b += cont;
        used[give[i].second - 1] = cont;
        plug[(*it).second] = give[i].second;
        S.erase(it);
        break;
      }
      cont++;
      if (aux == (aux + 1) / 2) break;
      aux = (aux + 1) / 2;
    }
  }
  cout << a << " " << b << endl;
  for (long long i = (0); i < (M); i++) {
    if (i) cout << " ";
    cout << used[i];
  }
  cout << endl;
  for (long long i = (0); i < (N); i++) {
    if (i) cout << " ";
    cout << plug[i];
  }
  cout << endl;
}
