#include <bits/stdc++.h>
const long long inf = 1e9;
const long double eps = 1e-6;
const long long N = 1e6;
const long long M = 1e6;
using namespace std;
void ret(string s) {
  cout << s;
  exit(0);
}
string s;
int a[100][100], b, ans = 0;
int mx, mn, len = 0, pos, n, k, h;
bool u[1000];
int main() {
  cin >> n >> k;
  pos = k - 1;
  for (int i = 0; i < k; i++) {
    cin >> h;
    a[i][0] = h;
    u[h] = true;
  }
  for (int i = 1; i <= n * k; i++)
    if (!u[i]) {
      pos++;
      if (pos == k) {
        pos = 0;
        len++;
      }
      a[pos][len] = i;
    }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j++) cout << a[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
