#include <bits/stdc++.h>
using namespace std;
struct classcomp {
  bool operator()(const int& lhs, const int& rhs) const { return lhs < rhs; }
};
int c[31];
int m[31 * 31];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    cin >> c[i];
    m[c[i]] = 1;
  }
  int counter = 1;
  for (int i = 1; i <= k; ++i) {
    cout << c[i];
    for (int j = 0; j < n - 1; j++) {
      while (m[counter] == 1) counter++;
      cout << " " << counter;
      counter++;
    }
    cout << endl;
  }
  return 0;
}
