#include <bits/stdc++.h>
int a[1000], b[35];
int main() {
  int n, k, x, cas = 1;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n * k; i++) {
    a[i] = i;
  }
  for (int i = 1; i <= k; i++) {
    scanf("%d", &b[i]);
    a[b[i]] = 0;
  }
  for (int i = 1; i <= k; i++) {
    int temp = 0;
    printf("%d ", b[i]);
    while (temp < n - 1) {
      if (a[cas] != 0) {
        printf("%d ", cas);
        temp++;
      }
      cas++;
    }
    printf("\n");
  }
}
