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