#include <bits/stdc++.h>
bool vis[1000000];
int a[100];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= k; i++) {
    scanf("%d", &a[i]);
    vis[a[i]] = 1;
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      if (j == 1) {
        printf("%d", a[i]);
        continue;
      } else {
        for (int z = 1; z <= n * k; z++) {
          if (!vis[z]) {
            printf(" %d", z);
            vis[z] = 1;
            break;
          }
        }
      }
    }
    printf("\n");
  }
}
