#include <bits/stdc++.h>
using namespace std;
int check[10000];
int main() {
  int n, k, x;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> x;
    check[x] = i + 1;
  }
  int counter = 0, j;
  for (int i = 0; i < k; i++) {
    counter = 0;
    for (j = 1; j <= n * k; j++) {
      if (check[j] == i + 1) {
        cout << j << " ";
        counter++;
      }
      if (counter == n) {
        cout << endl;
        break;
      }
    }
    j = 1;
    while (counter <= n) {
      if (!check[j]) {
        check[j] = i + 1;
        cout << j << " ";
        counter++;
      }
      if (counter == n) {
        cout << endl;
        break;
      }
      j++;
    }
  }
}
