#include <bits/stdc++.h>
int a[40][40];
int b[1000];
int main() {
  int n, k;
  while (scanf("%d%d", &n, &k) == 2) {
    int i, j, p;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    int x;
    for (i = 1; i <= k; i++) {
      scanf("%d", &x);
      b[x] = 1;
      a[i][0] = x;
    }
    for (i = 1; i <= k; i++) {
      for (j = 1; j < n; j++) {
        for (p = 1; p <= n * k; p++) {
          if (b[p] == 0) {
            a[i][j] = p;
            b[p] = 1;
            break;
          }
        }
      }
    }
    for (i = 1; i <= k; i++) {
      for (j = 0; j < n; j++) {
        printf("%d ", a[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}
