#include <bits/stdc++.h>
using namespace std;
const int N = 10e5;
const int oo = INT_MAX;
const int Noo = INT_MIN;
int O[905], O1[905];
void A(int n, int k) {
  int a;
  for (int i = 1; i < (int)k + 1; i++) {
    a = 1;
    cout << O[i] << " ";
    for (int j = 1; j < (int)(n * k) + 1; j++) {
      if (O1[j] != 1) {
        cout << j << " ";
        ++a;
        O1[j] = 1;
        if (a == n) break;
      }
    }
    cout << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  memset(O, 0, sizeof(O));
  memset(O1, 0, sizeof(O1));
  int n, k, x;
  cin >> n >> k;
  for (int i = 1; i < (int)k + 1; i++) {
    cin >> x;
    O[i] = x;
    O1[x] = 1;
  }
  A(n, k);
  return 0;
}
