#include <bits/stdc++.h>
using namespace std;
const int PRECISION = 10;
int flag[950];
int num[950];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.setf(ios::fixed),
      cout.setf(ios::showpoint), cout.precision(PRECISION);
  stack<int> stk;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    cin >> num[i];
    flag[num[i]] = 1;
  }
  for (int i = 1; i <= n * k; i++)
    if (flag[i] == 0) stk.push(i);
  for (int i = 1; i <= k; i++) {
    cout << num[i];
    for (int j = 1; j < n; j++) {
      cout << " " << stk.top();
      stk.pop();
    }
    cout << '\n';
  }
}
