#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const double EPS = 1e-9;
const double pi = acos(-1.0);
const long long MAXN = (long long)3e5 + 7;
const long long INF = (long long)1e9 + 7;
const long long LINF = (long long)1 << 63 - 5;
const long long MOD = (long long)2147482661;
const long long P = 239017;
const long long SZ = (long long)1e5;
int b[MAXN];
multiset<int> a;
map<int, vector<int>> mp;
int cnt[MAXN];
int kek[MAXN];
bool used[MAXN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a.insert(x);
    mp[x].push_back(i + 1);
  }
  int ans2 = 0;
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    b[i + 1] = x;
  }
  int ans = 0;
  for (int i = 0; i <= 40; i++) {
    for (int j = 1; j <= m; j++) {
      if (used[j]) continue;
      if (a.count(b[j]) != 0) {
        a.erase(a.find(b[j]));
        ans++;
        ans2 += cnt[j];
        kek[mp[b[j]].back()] = j;
        mp[b[j]].pop_back();
        used[j] = true;
      } else {
        b[j] = (b[j] + 1) / 2;
        cnt[j]++;
      }
    }
  }
  printf("%d %d\n", ans, ans2);
  for (int i = 1; i <= m; i++) {
    if (used[i])
      printf("%d ", cnt[i]);
    else
      printf("0 ");
  }
  printf("\n");
  for (int i = 1; i <= n; i++) printf("%d ", kek[i]);
  printf("\n");
  return 0;
}
