#include <bits/stdc++.h>
using namespace std;
template <typename T>
T bitCount(T x) {
  T c = 0;
  while (x) {
    x &= x - 1;
    c++;
  }
  return c;
}
void A_Dividing_Orange() {
  int n, k, j;
  bool taken[1000];
  int a[100];
  cin >> n >> k;
  memset(taken, 0, sizeof(taken));
  for (auto i = ((k) - (k)); (i) < (k); (i)++) {
    cin >> a[i];
    taken[a[i]] = true;
  }
  j = 1;
  for (auto ii = ((k) - (k)); (ii) < (k); (ii)++) {
    cout << a[ii] << " ";
    for (auto i = (1); (i) != (n); (i)++) {
      if (i - 1) cout << " ";
      while (taken[j]) j++;
      cout << j;
      j++;
    }
    cout << endl;
  }
}
int main() {
  A_Dividing_Orange();
  return 0;
}
