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