#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<pair<int, int>, int> > Q;
vector<pair<int, int> > tab;
pair<pair<int, int>, int> p;
int n, m, x, l1, l2, ans[200010], ans2[200010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int a = 1; a <= n; a++) {
    cin >> x;
    tab.push_back(make_pair(x, a));
  }
  sort(tab.begin(), tab.end());
  reverse(tab.begin(), tab.end());
  for (int a = 1; a <= m; a++) {
    cin >> x;
    Q.push(make_pair(make_pair(x, 0), a));
  }
  for (int a = 0; a < tab.size(); a++) {
    while (!Q.empty() && Q.top().first.first > tab[a].first) {
      p = Q.top();
      Q.pop();
      p.first.first = (p.first.first + 1) / 2;
      p.first.second *= -1;
      p.first.second++;
      p.first.second *= -1;
      Q.push(p);
    }
    if (!Q.empty() && tab[a].first == Q.top().first.first) {
      ans[tab[a].second] = Q.top().second;
      ans2[Q.top().second] = -Q.top().first.second;
      Q.pop();
    }
  }
  for (int a = 1; a <= n; a++)
    if (ans[a]) l1++;
  for (int a = 1; a <= m; a++) l2 += ans2[a];
  cout << l1 << " " << l2 << "\n";
  for (int a = 1; a <= m; a++) cout << ans2[a] << " ";
  cout << "\n";
  for (int a = 1; a <= n; a++) cout << ans[a] << " ";
  return 0;
}
