#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  int a[999], b[999];
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &a[i]);
    b[a[i]] = i;
  }
  int x = 1;
  int temp = k;
  while (temp--) {
    printf("%d ", a[x]);
    int num = n - 1;
    for (int i = 1; i <= n * k; i++) {
      if (b[i] == 0) {
        b[i] = -1;
        num--;
        if (num)
          printf("%d ", i);
        else {
          printf("%d\n", i);
          break;
        }
      }
    }
    x++;
  }
  return 0;
}
