#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  map<int, int> m;
  set<int> s;
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    m[i + 1] = x;
    s.insert(x);
  }
  int count = 1;
  for (int i = 0; i < k; i++) {
    cout << m[i + 1] << " ";
    for (int j = 2; j <= n; j++) {
      if (s.count(count) == 0) {
        cout << count << " ";
      } else
        j--;
      count++;
    }
    cout << endl;
  }
}
