#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, k, i, temp, p = 0;
  cin >> n >> k;
  vector<bool> check(n * k, false);
  vector<long long> dis[k];
  for (i = 0; i < k; i++) {
    cin >> temp;
    dis[i].push_back(temp - 1);
    check[temp - 1] = true;
  }
  for (i = 0; i < n * k; i++) {
    if (check[i] == false) {
      if (dis[p].size() < n) {
        dis[p].push_back(i);
      } else {
        dis[++p].push_back(i);
      }
    }
  }
  for (vector<long long> a : dis) {
    for (long long b : a) cout << b + 1 << " ";
    cout << "\n";
  }
  return 0;
}
