#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  int num[1000] = {0};
  int vis[1000] = {0};
  int t;
  for (int i = 0; i < k; i++) {
    cin >> vis[i];
    num[vis[i]] = 1;
  }
  int len = 0;
  for (int i = 0; i < k; i++) {
    len = 0;
    cout << vis[i] << " ";
    len++;
    for (int j = 1; j <= n * k; j++) {
      if (len < n && num[j] == 0) {
        cout << j;
        num[j] = 1;
        len++;
        if (len <= n - 1) {
          cout << " ";
        }
      }
    }
    cout << endl;
  }
  return 0;
}
