#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int flag[MAXN];
int math[MAXN];
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    memset(flag, -1, sizeof(flag));
    memset(math, 0, sizeof(math));
    for (int i = 0; i < k; i++) {
      scanf("%d", &math[i]);
      flag[math[i]] = i;
    }
    for (int i = 0; i < k; i++) {
      printf("%d ", math[i]);
      int num = n - 1;
      while (num) {
        for (int j = 1; j <= n * k; j++) {
          if (flag[j] == -1) {
            printf("%d ", j);
            flag[j] = -2;
            num--;
            if (num == 0) break;
          }
        }
      }
      printf("\n");
    }
  }
  return 0;
}
