#include <bits/stdc++.h>
using namespace std;
const int Inf = 1e9 + 7;
const int N = 200007;
int n, m;
int a[N], b[N];
pair<int, int> s[N];
map<int, vector<int> > M;
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    M[x].push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    s[i] = {x, i};
  }
  sort(s, s + m);
  int c = 0;
  int u = 0;
  for (int i = 0; i < m; ++i) {
    int x = s[i].first;
    int j = 0;
    while (x) {
      if (M.count(x)) {
        int y = M[x].back();
        a[s[i].second] = j;
        b[y] = s[i].second + 1;
        M[x].pop_back();
        if (M[x].empty()) M.erase(x);
        ++c;
        u += j;
        break;
      }
      if (x == 1) break;
      ++j;
      x = (x + 1) / 2;
    }
  }
  cout << c << " " << u << '\n';
  for (int i = 0; i < m; ++i) cout << a[i] << " ";
  cout << '\n';
  for (int i = 0; i < n; ++i) cout << b[i] << " ";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(9);
  cout << fixed;
  solve();
  return 0;
}
