#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007, BIG = 0x3f3f3f3f;
int n, k;
vector<int> a;
vector<vector<int> > Process() {
  vector<vector<int> > ans(k, vector<int>());
  vector<bool> vis(n * k + 5, 0);
  for (int i = 0; i < k; i++) {
    ans[i].push_back(a[i]);
    vis[a[i]] = 1;
  }
  int cur = 1;
  for (int i = 0; i < k; i++) {
    for (int j = 1; j < n; j++, cur++) {
      while (vis[cur]) cur++;
      ans[i].push_back(cur);
    }
  }
  return ans;
}
void Output() {
  const vector<vector<int> > ans = Process();
  for (int i = 0; i < ans.size(); i++) {
    for (int j = 0; j < ans[i].size(); j++) cout << ans[i][j] << " ";
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  while (cin >> n) {
    cin >> k;
    a.resize(k);
    for (int i = 0; i < k; i++) cin >> a[i];
    Output();
  }
  return 0;
}
