#include <bits/stdc++.h>
using namespace std;
int n, k, arr[31];
bool wanted[901];
int main() {
  memset(wanted, 0, sizeof(wanted));
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", &arr[i]);
    wanted[arr[i]] = 1;
  }
  for (int i = 0; i < k; i++) {
    cout << arr[i] << " ";
    int l = n - 1;
    for (int j = 1; j < n * k + 1; j++) {
      if (!wanted[j]) {
        wanted[j] = 1;
        cout << j << " ";
        l--;
        if (l == 0) break;
      }
    }
    cout << endl;
  }
  return 0;
}
