#include <bits/stdc++.h>
using namespace std;
const int maxn = 40;
int n, k, lim;
int output[maxn][maxn];
int cnt[maxn];
int m[maxn * maxn];
void printans() {
  for (int i = 0; i < k; i++) {
    if (i > 0) cout << endl;
    for (int j = 0; j < n; j++) {
      if (j > 0) cout << ' ';
      cout << output[i][j] + 1;
    }
  }
}
int dfs(int cur) {
  if (cur == lim) {
    printans();
    return 1;
  }
  if (m[cur] != -1) {
    if (dfs(cur + 1)) return 1;
  } else {
    for (int i = 0; i < n; i++)
      if (cnt[i] < n) {
        output[i][cnt[i]++] = cur;
        if (dfs(cur + 1)) return 1;
        cnt[i]--;
      }
  }
  return 0;
}
int main() {
  cin >> n >> k;
  memset(m, -1, sizeof(m));
  memset(cnt, 0, sizeof(cnt));
  lim = n * k;
  for (int i = 0; i < k; i++) {
    int tmp;
    cin >> tmp;
    m[tmp - 1] = i;
    output[i][cnt[i]++] = tmp - 1;
  }
  int t = 0;
  for (int i = 0; i < lim; i++)
    if (m[i] == -1) {
      while (cnt[t] >= n) t++;
      output[t][cnt[t]++] = i;
    }
  printans();
  return 0;
}
