#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  FILE *fp;
  fp = fopen("//home//mazhar//Desktop//in.txt", "r");
  if (fp != NULL) freopen("//home//mazhar//Desktop//in.txt", "r", stdin);
  int n, k, num;
  bool a[1000];
  int A[1000];
  memset(a, 0, sizeof(a));
  scanf("%d %d", &n, &k);
  for (int i = 0; i <= k - 1; i++) {
    scanf("%d", &num);
    a[num] = 1;
    A[i] = num;
  }
  int cnt;
  for (int i = 0; i <= k - 1; i++) {
    cout << A[i];
    cnt = 1;
    for (int j = 1; j <= n * k; j++) {
      if (cnt == n) break;
      if (a[j] == 0) {
        a[j] = 1;
        cnt++;
        cout << " " << j;
      }
    }
    cout << "\n";
  }
  return 0;
}
