#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1201;
int n, sd[N], gsd[N], group[N], rem_req[N];
vector<int> req_by[N], members[N];
int main() {
  cin >> n;
  n *= 6;
  for (int i = 0; i < n / 2; i++) {
    int x;
    cin >> x;
    x--;
    sd[x] = 1;
  }
  vector<int> cur;
  int nxt_group = 0;
  for (int i = 0; i < n; i++) {
    if (cur.empty() or gsd[cur.back()] != sd[i]) {
      gsd[nxt_group] = sd[i];
      group[i] = nxt_group;
      members[nxt_group].push_back(i);
      cur.push_back(nxt_group);
      nxt_group++;
    } else {
      int cur_group = cur.back();
      assert(sd[i] == gsd[cur_group]);
      group[i] = cur_group;
      members[cur_group].push_back(i);
      if (members[cur_group].size() == 3) {
        cur.pop_back();
        if (!cur.empty()) {
          req_by[cur_group].push_back(cur.back());
          rem_req[cur.back()]++;
        }
      }
    }
  }
  queue<int> ready[2];
  for (int i = 0; i < nxt_group; i++) {
    if (rem_req[i] == 0) {
      ready[gsd[i]].push(i);
    }
  }
  for (int i = 0; i < n / 6; i++) {
    for (int sd = 1; sd >= 0; sd--) {
      assert(!ready[sd].empty());
      int grp = ready[sd].front();
      ready[sd].pop();
      if (sd == 0 and req_by[grp].empty()) {
        ready[0].push(grp);
        grp = ready[0].front();
        ready[0].pop();
      }
      auto &m = members[grp];
      cout << m[0] + 1 << ' ' << m[1] + 1 << ' ' << m[2] + 1 << '\n';
      for (auto req_grp : req_by[grp]) {
        if (--rem_req[req_grp] == 0) {
          ready[gsd[req_grp]].push(req_grp);
        }
      }
    }
  }
}
