#include <bits/stdc++.h>
using namespace std;
const int N = 200009;
set<pair<int, int> > com;
pair<int, int> soc[N];
int a[N];
int b[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    com.insert({x, i});
  }
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    soc[i] = {x, i};
  }
  sort(soc, soc + m);
  int c = 0, u = 0;
  for (int i = 0; i < m; i++) {
    int s = soc[i].first;
    for (int t = 0;; t++, s = (s + 1) / 2) {
      auto p = com.lower_bound({s, -1});
      if (p != com.end() && p->first == s) {
        b[p->second] = soc[i].second + 1;
        a[soc[i].second] = t;
        u += t;
        c++;
        com.erase(p);
        break;
      }
      if (s == 1) break;
    }
  }
  printf("%d %d\n", c, u);
  for (int i = 0; i < m; i++) printf("%d ", a[i]);
  puts("");
  for (int i = 0; i < n; i++) printf("%d ", b[i]);
  puts("");
}
