#include <bits/stdc++.h>
using namespace std;
bool vis[1000];
int a[1000];
int main() {
  int n, k;
  while (cin >> n >> k) {
    for (int i = 1; i <= k; i++) {
      int x;
      cin >> x;
      a[i] = x;
      vis[x] = true;
    }
    int cnt = 1;
    for (int i = 1; i <= k; i++) {
      cout << a[i];
      int j = 1;
      while (j < n) {
        if (!vis[cnt]) {
          cout << ' ' << cnt;
          vis[cnt] = true;
          j++;
        }
        cnt++;
      }
      cout << endl;
    }
  }
  return 0;
}
