#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, a[35], p = 0, m[1000];
  for (int i = 0; i < 1000; i++) m[i] = i;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> a[i];
  }
  int q = 1;
  int w;
  for (int i = 0; i < k; i++) m[a[i]] = 0;
  for (int i = 0; i < k; i++) {
    cout << a[i];
    w = 1;
    while (1) {
      if (m[q]) {
        cout << " " << m[q];
        m[q] = 0;
        w++;
      }
      q++;
      if (w == n) break;
    }
    cout << endl;
  }
}
