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