#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[k], b[n * k];
  ;
  for (int i = 0; i < n * k; i++) {
    b[i] = i + 1;
  }
  for (int i = 0; i < k; i++) {
    cin >> a[i];
    b[a[i] - 1] = -2;
  }
  sort(b, b + n * k);
  int h = k;
  for (int i = 0; i < k; i++) {
    int d[n];
    d[0] = a[i];
    for (int j = 1; j < n; j++) {
      d[j] = b[h];
      h++;
    }
    sort(d, d + n);
    for (int j = 0; j < n; j++) {
      cout << d[j] << " ";
    }
    cout << endl;
  }
  return 0;
}
