#include <bits/stdc++.h>
const int maxn = 1e5 + 7;
int main() {
  int a, b, c, d, e, f, p[maxn], t[maxn];
  while (~scanf("%d%d", &a, &b)) {
    for (int i = 1; i <= b; i++) {
      scanf("%d", &c);
      t[i] = c;
      p[c] = 1;
    }
    int flag = 1, num = 1, q = 1;
    while (num <= a * b) {
      if (p[num] == 1) {
        num++;
      } else if (p[num] == 0 && flag <= a - 1) {
        p[num] = 1;
        flag++;
        printf("%d ", num);
        num++;
      }
      if (flag == a) {
        printf("%d\n", t[q]);
        flag = 1;
        q++;
      }
    }
  }
}
