#include <bits/stdc++.h>
using namespace std;
int s[10000], t[1000];
int main() {
  int i, j, n, m, a, b, c, d;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> t[i];
    s[t[i]] = 1;
  }
  c = n * m;
  b = 1;
  for (i = 1; i <= m; i++) {
    cout << t[i];
    d = 1;
    for (j = 1; j <= c; j++) {
      if (s[j] == 0) {
        cout << " " << j;
        s[j] = 3;
        d++;
        if (d % n == 0) break;
      }
    }
    cout << endl;
  }
  return 0;
}
