#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  set<int> s;
  cin >> n >> k;
  vector<int> a(k);
  vector<pair<int, bool> > c(n * k);
  int count = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      c[count - 1].first = count;
      c[count - 1].second = true;
      count++;
    }
  }
  for (int i = 0; i < k; i++) {
    cin >> a[i];
    c[a[i] - 1].second = false;
  }
  count = 0;
  for (int i = 0; i < k; i++) {
    cout << a[i] << " ";
    for (int j = 0; j < n - 1; j++) {
      if (!c[count].second) {
        j--;
        count++;
        continue;
      }
      cout << c[count++].first << " ";
    }
    cout << "\n";
  }
  return 0;
}
