#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 3e5 + 5;
const int oo = 1e9 + 7;
int n, k;
int c[N];
int m[N];
bool pos(int len) {
  priority_queue<int> pq;
  for (int i = 1; i <= len; i++) pq.push(0);
  for (int i = n; i >= 1; i--) {
    int sz = m[i];
    int tp = -pq.top();
    if (tp < c[sz]) {
      tp++;
      pq.pop();
      pq.push(-tp);
    } else
      return 0;
  }
  return 1;
}
vector<int> ans[N];
void print(int len) {
  priority_queue<pair<int, int> > pq;
  for (int i = 1; i <= len; i++) pq.push({0, i});
  for (int i = n; i >= 1; i--) {
    int sz = m[i];
    int tp = -pq.top().first;
    int id = pq.top().second;
    if (tp < c[sz]) {
      ans[id].push_back(sz);
      tp++;
      pq.pop();
      pq.push({-tp, id});
    } else
      assert(0);
  }
  cout << len << "\n";
  for (int i = 1; i <= len; i++) {
    cout << ans[i].size();
    for (int j : ans[i]) cout << " " << j;
    cout << "\n";
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> m[i];
  for (int i = 1; i <= k; i++) cin >> c[i];
  sort(m + 1, m + n + 1);
  int lo = 1, hi = n, mid;
  while (lo < hi) {
    mid = (lo + hi) / 2;
    if (pos(mid))
      hi = mid;
    else
      lo = mid + 1;
  }
  print(hi);
}
