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