#include <bits/stdc++.h>
using namespace std;
int n, k, v[1000], peguei[1000], menor;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", v + i);
    peguei[v[i]] = 1;
  }
  menor = 1;
  for (int i = 0; i < k; i++) {
    printf("%d ", v[i]);
    for (int j = 0; j < n - 1; j++) {
      while (peguei[menor]) menor++;
      printf("%d ", menor);
      peguei[menor] = 1;
      menor++;
    }
    printf("\n");
  }
}
