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