#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int no[N * K], temp[K];
  memset(no, 0, sizeof(no));
  for (int i = 0; i < K; i++) {
    cin >> temp[i];
    no[temp[i] - 1] = 1;
  }
  int x = 0, y;
  for (int i = 0; i < K; i++) {
    cout << temp[i];
    y = 0;
    while (y < N - 1) {
      if (no[x] == 0) {
        cout << " " << x + 1;
        y++;
      }
      x++;
    }
    cout << "\n";
  }
  return 0;
}
