#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> v(n * k + 1, false);
  vector<int> g(k);
  for (int i = 0; i < k; ++i) {
    cin >> g[i];
    v[g[i]] = true;
  }
  for (int i = 0; i < k; ++i) {
    cout << g[i] << " ";
    for (int j = 0; j < n - 1; ++j) {
      for (int q = 1; q < n * k + 1; ++q) {
        if (!v[q]) {
          v[q] = true;
          cout << q << " ";
          break;
        }
      }
    }
    cout << endl;
  }
  return 0;
}
