#include <bits/stdc++.h>
int a[100000] = {0}, check[1000000] = {0};
int main() {
  int i, j, k, n, last = 0, count;
  scanf("%d %d", &n, &k);
  for (i = 0; i < k; i++) {
    scanf("%d", &a[i]);
    check[a[i]] = 1;
  }
  last = 1;
  for (i = 0; i < k; i++) {
    count = 0;
    printf("%d ", a[i]);
    for (j = 1; j <= n * k; j++) {
      if (check[j] == 0) {
        printf("%d ", j);
        count++;
        check[j] = 1;
        if (count == n - 1) break;
      }
    }
    printf("\n");
  }
  return 0;
}
