#include <bits/stdc++.h>
int hash[1001];
int a[1001];
int n, k;
int tot = 0;
int flag = 0;
int main() {
  int i;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= k; i++) {
    scanf("%d", &a[i]);
    hash[a[i]] = 1;
  }
  flag = 1;
  for (i = 1; i <= k; i++) {
    printf("%d", a[i]);
    tot = 1;
    while (tot < n) {
      while (hash[flag]) flag++;
      hash[flag] = 1;
      printf(" %d", flag);
      tot++;
    }
    printf("\n");
  }
  return 0;
}
