#include <bits/stdc++.h>
using namespace std;
const int N = 35;
int nums[N];
bool used[N * N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    cin >> nums[i];
    used[nums[i]] = true;
  }
  vector<int> canUse;
  for (int i = 1; i <= n * k; i++)
    if (!used[i]) canUse.push_back(i);
  vector<int> anss[N];
  for (int i = 1; i <= k; i++) anss[i].push_back(nums[i]);
  int ptr = 1;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j < n; j++)
      anss[i].push_back(canUse.back()), canUse.pop_back();
  }
  for (int i = 1; i <= k; i++) {
    for (int j : anss[i]) cout << j << " ";
    cout << "\n";
  }
  return 0;
}
