#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[k];
  map<long long, bool> m;
  for (long long i = 0; i < k; i++) {
    cin >> a[i];
    m[a[i]] = true;
  }
  long long cnt = 1;
  for (long long i = 0; i < k; i++) {
    cout << a[i];
    for (long long i = 0; i < n - 1; i++) {
      if (!m[cnt])
        cout << " " << cnt;
      else
        i--;
      cnt++;
    }
    cout << endl;
  }
  return 0;
}
