#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n;
  cin >> n >> k;
  int a[k];
  for (int i = 0; i < k; i++) {
    cin >> a[i];
  }
  int c = 0;
  int f = n * k;
  for (int p = 0; p < k; p++) {
    cout << a[p] << " ";
    for (int i = 1; i < n; i++) {
      c += 1;
      for (int z = 0; z < k; z++) {
        if (c == a[z]) {
          c++;
          z = -1;
        }
      }
      cout << c;
      if (i != n - 1) {
        cout << " ";
      }
    }
    cout << endl;
  }
}
