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