#include <bits/stdc++.h>
using namespace std;
vector<int> v[35];
bool d[905];
void input() {
  int i, j, k, n, n2, idx, cnt, x;
  scanf("%d %d", &n, &k);
  for ((i) = 0; (i) < (k); (i)++)
    scanf("%d", &x), v[i].push_back(x), d[x] = true;
  idx = 0, cnt = 1;
  n2 = n * k;
  for ((i) = (1); (i) <= (n2); (i)++)
    if (!d[i]) {
      v[idx].push_back(i);
      cnt++;
      if (cnt == n) idx++, cnt = 1;
    }
  for ((i) = 0; (i) < (k); (i)++) {
    for ((j) = 0; (j) < (v[i].size()); (j)++) printf("%d ", v[i][j]);
    printf("\n");
  }
}
int main() {
  input();
  return 0;
}
