#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> arr(n * k + 1, false);
  vector<int> t(k);
  for (int i = 0; i < k; i++) {
    cin >> t[i];
    arr[t[i]] = true;
  }
  int curr = 1, m;
  for (int i = 0; i < k; i++) {
    m = 1;
    cout << t[i] << " ";
    while (m < n) {
      if (!arr[curr]) {
        m++;
        cout << curr << " ";
      }
      curr++;
    }
    cout << "\n";
  }
  return 0;
}
