#include <bits/stdc++.h>
using namespace std;
int check(vector<long long> v, long long k, long long c) {
  for (long long i = 0; i < k; i++) {
    if (v[i] == c) {
      return 0;
    }
  }
  return 1;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v;
  for (long long i = 0; i < k; i++) {
    long long t;
    cin >> t;
    v.push_back(t);
  }
  long long count = 1;
  for (long long i = 0; i < k; i++) {
    cout << v[i] << " ";
    long long che = 0;
    while (che != n - 1) {
      if (check(v, k, count)) {
        cout << count << " ";
        che++;
      }
      count++;
    }
    cout << endl;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
