#include <bits/stdc++.h>
using namespace std;
queue<int> v;
bool used[10001];
int ko = 100000, m, k, ans, n, a[(int)1e5], b[1000];
set<int> s;
int main() {
  setlocale(LC_ALL, "Rus");
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    scanf("%d", a + i);
    used[a[i]] = true;
  }
  int t = 1;
  int j = 1;
  for (int i = 1; i <= k; i++) {
    cout << a[i] << ' ';
    j = n - 1;
    while (j) {
      if (!used[t]) {
        cout << t << ' ';
        j--;
        used[t] = true;
      }
      t++;
    }
    cout << endl;
  }
  return 0;
}
