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