#include <bits/stdc++.h>
using namespace std;
int b[1005], a[1005];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  memset(b, 0, sizeof(b));
  for (int i = 0; i < k; i++) {
    scanf("%d", &a[i]);
    b[a[i]] = 1;
  }
  int q = 1;
  for (int i = 0; i < k; i++) {
    printf("%d", a[i]);
    for (int j = 0; j < n - 1;) {
      if (!b[q]) {
        printf(" %d", q);
        j++;
      }
      q++;
    }
    puts("");
  }
  return 0;
}
