#include <bits/stdc++.h>
const long long INF = 1LL << 61;
const int inf = 2e9;
bool debug;
using namespace std;
void solve();
int main() {
  debug = 0;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
const int N = 200005;
map<int, vector<int>> gr;
int n, m, x, a[N], b[N];
pair<int, int> s[N];
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    gr[x].push_back(i);
  }
  for (int i = 1; i <= m; i++) cin >> s[i].first, s[i].second = i;
  sort(s + 1, s + m + 1);
  for (int i = 1; i <= m; i++) {
    int add = 0;
    while (228) {
      if ((int)gr[s[i].first].size()) {
        int v = gr[s[i].first].back();
        gr[s[i].first].pop_back();
        a[s[i].second] = add;
        b[v] = s[i].second;
        break;
      }
      if (s[i].first == 1)
        break;
      else
        s[i].first = s[i].first / 2 + s[i].first % 2, add++;
    }
  }
  int c = 0, u = 0;
  for (int i = 1; i <= m; i++) u += a[i];
  for (int i = 1; i <= n; i++) c += bool(b[i]);
  cout << c << " " << u << endl;
  for (int i = 1; i <= m; i++) cout << a[i] << " ";
  cout << endl;
  for (int i = 1; i <= n; i++) cout << b[i] << " ";
  cout << endl;
}
