#include <bits/stdc++.h>
using namespace std;
long long dp[26];
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[k];
  set<long long> s;
  for (long long i = 0; i < k; i++) {
    long long first;
    cin >> first;
    a[i] = first;
    s.insert(first);
  }
  set<long long>::iterator itr;
  itr = s.begin();
  for (long long i = 0; i < k; i++) {
    long long cnt = 1;
    cout << a[i] << " ";
    itr++;
    for (long long j = 1; j <= n * k && cnt < n; j++) {
      if (s.count(j) == 0) {
        cout << j << " ";
        s.insert(j);
        cnt++;
      }
    }
    cout << '\n';
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
