#include <bits/stdc++.h>
using namespace std;
int vis[50 * 50];
int a[50];
int cmd[50];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    cmd[i] = x;
    vis[x] = 1;
  }
  for (int i = 0; i < k; i++) {
    printf("%d ", cmd[i]);
    int ctr = 0, idx = 1;
    while (ctr < n - 1) {
      if (vis[idx] == 0) {
        printf("%d ", idx);
        vis[idx] = 1;
        ctr++;
      }
      idx++;
    }
    puts("");
  }
  return 0;
}
