#include <bits/stdc++.h>
using namespace std;
int n, k, a, f[50 * 50];
vector<int> v[50];
int main() {
  scanf("%d%d", &n, &k);
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= k; i++) {
    scanf("%d", &a);
    f[a] = i;
    v[i].push_back(a);
  }
  for (int i = 1; i <= k; i++) {
    printf("%d", v[i][0]);
    for (int j = 1; j <= n * k; j++) {
      if (v[i].size() == n) break;
      if (f[j] == 0) {
        f[j] = i;
        v[i].push_back(j);
        printf(" %d", j);
      }
    }
    printf("\n");
  }
  return 0;
}
