#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[1000];
  int b[1000];
  for (int i = 0; i < 1000; i++) a[i] = 1;
  int n, k, r = 1, fl;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> b[i];
    a[b[i]] = 0;
  }
  for (int i = 0; i < k; i++) {
    fl = 1;
    cout << b[i] << " ";
    while (fl < n) {
      if (a[r] != 0) {
        cout << r << " ";
        fl++;
        a[r] = 0;
      }
      r++;
    }
    cout << endl;
  }
  return 0;
}
