#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c = 0;
  cin >> n >> k;
  int a[123456] = {0}, v[123456] = {0};
  bool b[123456] = {false};
  for (int i = 1; i <= k; i++) {
    cin >> a[i];
    v[i] = a[i];
    b[a[i]] = true;
  }
  for (int i = 1; i <= k; i++) {
    cout << v[i] << " ";
    c = 0;
    for (int j = 1; j <= n * k; j++) {
      if (b[j] == false) {
        c++;
        if (c == n) {
          break;
        }
        cout << j << " ";
        b[j] = true;
      }
    }
    cout << endl;
  }
  return 0;
}
