#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  bool arr[n * k];
  for (int i = 0; i < n * k; i++) arr[i] = true;
  int ar[k];
  int temp;
  for (int i = 0; i < k; i++) {
    cin >> temp;
    ar[i] = temp;
    arr[temp - 1] = false;
  }
  int count = 0;
  int index = 0;
  for (int i = 0; i < n * k; i++) {
    if (i % n == 0) {
      cout << ar[index] << " ";
      index++;
    } else {
      if (arr[count]) {
        cout << count + 1 << " ";
        count++;
      } else {
        count++;
        i--;
      }
    }
  }
  return 0;
}
