#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, a[101] = {0};
  bool f = true;
  cin >> n >> k;
  for (int i = 0; i < k; i++) cin >> a[i];
  queue<int> q;
  for (int j = 1; j <= n * k; j++) {
    for (int i = 0; i < k; i++)
      if (a[i] == j) f = false;
    if (f) q.push(j);
    f = true;
  }
  for (int i = 0; i < k; i++) {
    cout << a[i] << " ";
    for (int j = 0; j < n - 1; j++) {
      cout << q.front() << " ";
      q.pop();
    }
    cout << endl;
  }
  return 0;
}
