#include <bits/stdc++.h>
using namespace std;
int buf_a;
inline int in() {
  scanf("%d", &buf_a);
  return buf_a;
}
void readf(string s) {
  string i = s + ".in";
  string o = s + ".out";
  freopen(i.c_str(), "r", stdin);
  freopen(o.c_str(), "w", stdout);
}
const int INF = ~(1 << 31);
const long long LINF = ~(1ll << 63);
int main() {
  int n = in(), k = in();
  set<int> ue;
  vector<int> num;
  for (int i = 0; i < k; ++i) {
    int p = in();
    ue.insert(p);
    num.push_back(p);
  }
  int t = 1;
  for (int i = 0; i < k; ++i) {
    printf("%d ", num[i]);
    for (int j = 0; j < n - 1; ++j) {
      while (ue.count(t) > 0) ++t;
      printf("%d ", t);
      ++t;
    }
    puts("");
  }
  return 0;
}
