#include <bits/stdc++.h>
const long long max9 = 10 + 1e9, max6 = 10 + 1e6, max12 = 10 + 1e12,
                max15 = 10 + 1e15;
const long long min6 = -1 * max6, min9 = -1 * max9, min12 = -1 * max12,
                min15 = -1 * max15;
const long long R = 7 + 1e9, NN = 10 + 1e5;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  bool a[n * k + 1];
  memset(a, false, sizeof(a));
  int t[k];
  for (int i = (0); i < (k); ++i) cin >> t[i];
  for (int i = (0); i < (k); ++i) {
    a[t[i] - 1] = true;
  }
  for (int i = (0); i < (k); ++i) {
    cout << t[i] << " ";
    int o = 1;
    for (int j = (0); j < (n * k + 1); ++j) {
      if (!a[j]) {
        cout << j + 1 << " ";
        o++;
        a[j] = true;
      }
      if (o == n) {
        cout << endl;
        break;
      }
    }
  }
  return 0;
}
