#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<int> > g;
  vector<int> buf;
  g.clear();
  buf.clear();
  for (int i = 0; i < k; i++) g.push_back(buf);
  vector<int> num;
  num.clear();
  int j;
  for (j = 0; j < n * k; j++) num.push_back(0);
  for (int i = 0; i < k; i++) {
    int c;
    cin >> c;
    g[i].push_back(c);
    num[c - 1] = 1;
  }
  int l = 0;
  for (j = 0; j < n * k; j++)
    if (num[j] == 0) {
      g[l].push_back(j + 1);
      l++;
      if (l == k) l = 0;
    }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j++) cout << g[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}
