#include <bits/stdc++.h>
int main() {
  int n, k, p[35], usad[35 * 35];
  memset(p, 0, sizeof(p));
  memset(usad, 0, sizeof(usad));
  scanf(" %d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    scanf(" %d", &p[i]);
    usad[p[i]] = 1;
  }
  for (int i = 0; i < k; i++) {
    printf("%d", p[i]);
    int j = 1, w = 1;
    for (; j <= n * k && w < n; j++) {
      if (!usad[j]) {
        printf(" %d", j);
        w++;
        usad[j] = 1;
      }
    }
    printf("\n");
  }
  return 0;
}
