#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[k], b[n * k], c[(n * k) - k + 1];
  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] = 0;
  }
  int m = 0;
  for (int i = 0; i < (n * k); i++) {
    if (b[i] == 0) continue;
    c[m] = b[i];
    m++;
  }
  m = 0;
  if ((n * k) == k) {
    for (int i = 0; i < k; i++) cout << a[i] << "\n";
    return 0;
  }
  for (int i = 0; i < k; i++) {
    cout << a[i] << " ";
    for (int j = 0; j < n - 1; j++) {
      cout << c[m + j] << " ";
    }
    m += n - 1;
    cout << "\n";
  }
}
