#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int v1[1000];
    memset(v1, 0, sizeof v1);
    int a[k];
    for (int i = 0; i < k; i++) {
      cin >> a[i];
      v1[a[i]]++;
    }
    for (int i = 0; i < k; i++) {
      cout << a[i] << " ";
      for (int p = 1; p < n; p++) {
        for (int j = 1; j <= n * k; j++) {
          if (v1[j] == 0) {
            cout << j << " ";
            v1[j]++;
            break;
          }
        }
      }
      cout << endl;
    }
  }
  return 0;
}
