#include <bits/stdc++.h>
using namespace std;
void solve();
int main() { solve(); }
void solve() {
  int n, k;
  cin >> n >> k;
  set<int> slices;
  for (int i = 1; i <= n * k; i++) {
    slices.insert(i);
  }
  vector<set<int>> wants;
  for (int i = 1; i <= k; i++) {
    int t;
    cin >> t;
    set<int> temps;
    temps.insert(t);
    slices.erase(t);
    wants.push_back(temps);
  }
  auto ptr = slices.begin();
  for (auto ts = wants.begin(); ts != wants.end(); ts++) {
    for (int j = 1; j < n; j++) {
      (*ts).insert(*ptr);
      ptr++;
    }
  }
  for (auto ts : wants) {
    for (auto v : ts) {
      cout << v << " ";
    }
    cout << endl;
  }
}
