#include <bits/stdc++.h>
using namespace std;
int n, k, a[1000];
bool check[1000];
int main() {
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> a[i];
    check[a[i]] = true;
  }
  for (int i = 0; i < k; i++) {
    cout << a[i] << " ";
    int cnt = 1;
    for (int j = 1; j <= n * k; j++) {
      if (check[j]) continue;
      if (cnt == n) break;
      cnt++;
      cout << j << " ";
      check[j] = true;
    }
    cout << endl;
  }
  return 0;
}
