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