#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int* flag = new int[n * k];
  for (int i = 0; i < n * k; ++i) flag[i] = 1;
  int* a = new int[k];
  for (int i = 0; i < k; ++i) cin >> a[i], flag[a[i] - 1] = 0;
  for (int i = 0; i < k; ++i) {
    cout << a[i];
    for (int j = 0, c = 1; j < n * k; ++j) {
      if (flag[j] && c != n) cout << " " << j + 1, flag[j] = 0, ++c;
      if (c == n) break;
    }
    cout << endl;
  }
  return 0;
}
