#include <bits/stdc++.h>
using namespace std;
void no(int ex = -1) { cout << ex << "\n"; }
void bl(bool win) {
  if (win)
    cout << "YES";
  else
    cout << "NO";
  cout << "\n";
}
const int N = 2 * 10e5;
const int mod = 998244353;
vector<bool> pr;
void prime() {
  int EDGE = 1000;
  pr = vector<bool>(EDGE);
  for (int i = 0; i < EDGE; i++) pr[i] = true;
  pr[0] = false;
  pr[1] = false;
  for (int i = 2; i < EDGE; i++) {
    if (pr[i]) {
      if (i * i < EDGE) {
        for (int j = i * i; j < EDGE; j += i) pr[j] = false;
      }
    }
  }
}
long long nod(long long a1, long long b1) {
  if (b1 == 0)
    return a1;
  else
    return nod(b1, a1 % b1);
}
long long T;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> mn(n);
  for (int i = 0; i < int(n); i++) {
    cin >> mn[i];
  }
  vector<int> res(k);
  for (int i = 0; i < int(k); i++) {
    cin >> res[i];
  }
  vector<int> ab = {0, 0, 0, 1};
  vector<int>::iterator hig;
  hig = lower_bound(ab.begin(), ab.end(), 1);
  vector<vector<int>> ans(n, {0});
  sort(mn.begin(), mn.end());
  vector<int> us(n, 0);
  int cnt = 0;
  for (int z = n - 1; z >= 0; z--) {
    vector<int>::iterator low;
    low = lower_bound(us.begin(), us.end(), res[mn[z] - 1]);
    int y = low - us.begin();
    y = min(n - 1, y);
    if (us[y] == res[mn[z] - 1]) y--;
    ans[n - y - 1][0]++;
    us[y]++;
    ans[n - y - 1].push_back(mn[z]);
  }
  int cur = 0;
  while (cur < n && ans[cur][0] != 0) {
    cur++;
  }
  cout << cur << "\n";
  for (int i = 0; i < cur; i++) {
    for (int j = 0; j <= ans[i][0]; j++) cout << ans[i][j] << " ";
    cout << "\n";
  }
}
