#include <bits/stdc++.h>
using namespace std;
int n, k, c = 1, l;
int a[905], b[905];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &l);
    a[l]++;
    b[i] = l;
  }
  for (int i = 1; i <= k; i++) {
    cout << b[i] << " ";
    for (int j = 1; j < n; j++) {
      if (!a[c])
        cout << c++ << " ";
      else {
        while (a[c] == 1) c++;
        printf("%d ", c++);
      }
    }
    printf(" \n");
  }
  return 0;
}
