#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, f, g, h;
string s;
vector<long long> vc, vb;
int main() {
  cin >> a >> b;
  for (long long i = 0; i < b; i++) {
    cin >> c;
    vb.push_back(c);
  }
  for (long long i = 0; i < a * b; i++) {
    for (long long j = 0; j < b; j++) {
      if (vb[j] == i + 1) {
        d = 1;
      }
    }
    if (d != 1) {
      vc.push_back(i + 1);
    }
    d = 0;
  }
  for (long long i = 0; i < vb.size(); i++) {
    cout << vb[i] << " ";
    for (long long j = e; j < vc.size(); j++) {
      cout << vc[j] << " ";
      e++;
      f++;
      if (f == a - 1) {
        f = 0;
        break;
      }
    }
    cout << "\n";
  }
}
