#include <bits/stdc++.h>
using namespace std;
const int MAX = 35;
int a[MAX];
set<int> taken;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = (0); i < (k); ++i) {
    scanf("%d", &a[i]);
    taken.insert(a[i]);
  }
  int d = 1;
  for (int i = (0); i < (k); ++i) {
    printf("%d ", a[i]);
    for (int j = (0); j < (n - 1); ++j) {
      while (taken.count(d)) d++;
      printf("%d ", d);
      d++;
    }
    printf("\n");
  }
  return 0;
}
