#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
int n, k;
int a[1000];
int zan[1000];
int main() {
  cin >> n >> k;
  memset(zan, 0, sizeof(zan));
  memset(a, 0, sizeof(a));
  for (int i = 0; i < k; i++) {
    cin >> a[i];
    zan[a[i]] = 1;
  }
  int used = 0;
  for (int i = 0; i < k; i++) {
    cout << a[i] << " ";
    for (int j = 0; j < n - 1; j++) {
      used++;
      while (zan[used]) used++;
      cout << used << " ";
    }
    cout << "\n";
  }
  return 0;
}
