#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, j, p;
  bool visited[1000];
  unordered_map<int, int> m;
  int a[1000];
  cin >> n >> k;
  for (i = 1; i <= n * k; i++) {
    visited[i] = false;
  }
  for (i = 1; i <= k; i++) {
    cin >> a[i];
    m[i] = a[i];
    visited[a[i]] = true;
  }
  for (i = 1; i <= k; i++) {
    cout << m[i] << " ";
    for (j = 1, p = 1; j <= n * k && p <= n - 1; j++) {
      if (!visited[j]) {
        cout << j << " ";
        p++;
        visited[j] = true;
      }
    }
    cout << endl;
  }
  return 0;
}
