#include <bits/stdc++.h>
int a[1005], vis[1005];
int main() {
  int n, k, t;
  memset(vis, 1, sizeof(vis));
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &a[i]);
    vis[a[i]] = 0;
  }
  for (int i = 1, j = 1; i <= k; i++) {
    t = n - 1;
    printf("%d", a[i]);
    while (t) {
      if (vis[j]) {
        printf(" ");
        printf("%d", j);
        t--;
      }
      j++;
    }
    printf("\n");
  }
  return 0;
}
