#include <bits/stdc++.h>
using namespace std;
const long long int inf = INT_MAX;
const long double eps = 0.0000001;
const long double PI = acos(-1.0);
const long long int MOD = 1e9 + 7;
const long long int N = 150005;
long long int cnt[905];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  long long int a[k];
  for (long long int i = 0; i < k; ++i) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  long long int kk = 1;
  for (long long int i = 0; i < k; ++i) {
    for (long long int j = 0; j < n - 1;) {
      if (cnt[kk] == 0) {
        cnt[kk] = 1;
        cout << kk << " ";
        j++;
        kk++;
      } else
        kk++;
    }
    cout << a[i] << '\n';
  }
  return 0;
}
