#include <bits/stdc++.h>
using namespace std;
const int MAX = 200010;
int s[MAX], a[MAX], b[MAX], vis[MAX];
struct Node {
  int x, v;
  bool operator<(const Node& args) const { return v < args.v; }
};
void init() {
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  memset(vis, 0, sizeof(vis));
}
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    multiset<Node> P;
    Node tmp;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &tmp.v);
      tmp.x = i;
      P.insert(tmp);
    }
    for (int i = 1; i <= m; i++) {
      scanf("%d", &s[i]);
    }
    init();
    int cnt = 0, u = 0, c = 0;
    while (cnt <= 31) {
      multiset<Node>::iterator it;
      for (int i = 1; i <= m; i++)
        if (!vis[i]) {
          tmp.x = 0;
          tmp.v = s[i];
          it = P.find(tmp);
          if (it != P.end()) {
            b[it->x] = i;
            a[i] = cnt;
            c++;
            u += cnt;
            vis[i] = 1;
            P.erase(it);
          }
        }
      for (int i = 1; i <= m; i++) s[i] = (s[i] + 1) / 2;
      cnt++;
    }
    printf("%d %d\n", c, u);
    printf("%d", a[1]);
    for (int i = 2; i <= m; i++) printf(" %d", a[i]);
    printf("\n");
    printf("%d", b[1]);
    for (int i = 2; i <= n; i++) printf(" %d", b[i]);
    printf("\n");
  }
  return 0;
}
