#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> list;
  vector<int> children(k);
  for (int i = 0; i < k; i++) cin >> children[i];
  bool flag = 0;
  for (int i = 1; i <= ((n * k)); i++) {
    for (int j = 0; j < k; j++) {
      if (i == children[j]) flag = 1;
    }
    if (!flag) list.push_back(i);
    flag = 0;
  }
  int cnt = 0;
  for (int i = 0; i < k; i++) {
    cout << children[i] << " ";
    for (int j = 0; j < (n - 1); j++) {
      cout << list[cnt] << " ";
      cnt++;
    }
    cout << endl;
  }
  return 0;
}
