#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
int x[maxn];
int vis[maxn];
int main() {
  int n, k;
  memset(vis, 0, sizeof(vis));
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &x[i]);
    vis[x[i]] = 1;
  }
  for (int i = 1; i <= k; i++) {
    printf("%d ", x[i]);
    int num = 1;
    for (int j = 1; j <= n * k; j++) {
      if (!vis[j]) {
        num++;
        printf("%d ", j);
        vis[j] = 1;
      }
      if (num == n) break;
    }
    puts("");
  }
  return 0;
}
