#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T b, T p, T M) {
  long long ret = 1;
  for (; p > 0; p >>= 1) {
    if (p & 1) ret = (ret * b) % M;
    b = (b * b) % M;
  }
  return (T)ret;
}
template <class T>
inline T lcm(T a, T b) {
  return (a * b) / __gcd(a, b);
}
int dx4[] = {1, 0, -1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, -1, 0, 1, -1, 0, 1};
int kx8[] = {1, 1, 2, 2, -1, -1, -2, -2};
int ky8[] = {2, -2, 1, -1, 2, -2, 1, -1};
const double PI = acos(-1.0), EPS = 1e-7;
const long long INF = (long long)1e18 + 7;
const int N = 2e5 + 5, M = 1e9 + 7;
int n, m, p[N], s[N], ptr;
map<int, int> mp;
priority_queue<pair<int, pair<int, int> > > pq;
vector<int> pos[N];
int cnt[N], id[N], ad[N], soc[N];
int main() {
  cin >> n >> m;
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &p[i]);
    if (mp.find(p[i]) == mp.end()) mp[p[i]] = ++ptr;
    pos[mp[p[i]]].push_back(i);
    cnt[mp[p[i]]]++;
  }
  for (int i = 1; i < m + 1; i++) {
    scanf("%d", &s[i]);
    pq.push(make_pair(s[i], make_pair(0, i)));
  }
  int C = 0, U = 0;
  while (!pq.empty()) {
    pair<int, pair<int, int> > u = pq.top();
    pq.pop();
    int used = 0;
    if (mp.find(u.first) != mp.end()) {
      int d = mp[u.first];
      if (cnt[d]) {
        cnt[d]--;
        used = 1;
        C++;
        U -= u.second.first;
        soc[pos[d][id[d]]] = u.second.second;
        id[d]++;
        ad[u.second.second] = -u.second.first;
      }
    }
    if (!used && u.first > 1) {
      pq.push(make_pair((u.first + 1) / 2,
                        make_pair(u.second.first - 1, u.second.second)));
    }
  }
  printf("%d %d\n", C, U);
  for (int i = 1; i < m + 1; i++) printf("%d ", ad[i]);
  printf("\n");
  for (int i = 1; i < n + 1; i++) printf("%d ", soc[i]);
  printf("\n");
  return 0;
}
