#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[k + 1];
  int vis[n * k + 1];
  for (int i = 1; i <= n * k; i++) vis[i] = 0;
  for (int i = 1; i <= k; i++) {
    cin >> a[i];
    vis[a[i]] = 1;
  }
  vector<int> v[k + 1];
  for (int i = 1; i <= k; i++) v[i].push_back(a[i]);
  for (int i = 1; i <= k; i++) {
    int cnt = 1;
    for (int j = 1; j <= n * k; j++) {
      if (cnt == n) break;
      if (vis[j] == 0) {
        v[i].push_back(j);
        vis[j] = 1;
        cnt++;
      }
    }
  }
  vector<int>::iterator it;
  for (int i = 1; i <= k; i++) {
    for (it = v[i].begin(); it != v[i].end(); it++) {
      cout << *it << " ";
    }
    cout << endl;
  }
  return 0;
}
