#include <bits/stdc++.h>
using namespace std;
const int maxn = 900 + 20;
int n, k, a[maxn], b[maxn], g, p = 1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> a[i];
    b[a[i]] += 1;
  }
  for (int i = 0; i < k; i++) {
    cout << a[i] << " ";
    g = n - 1;
    while (g != 0) {
      if (b[p] == 0) {
        g--;
        b[p] += 1;
        cout << p << " ";
      }
      p++;
    }
    cout << endl;
    p = 1;
  }
  return 0;
}
