#include <bits/stdc++.h>
using namespace std;
const int N = 205;
struct Node {
  int cnt, c[3], fa, deg, pl, vis;
};
bool pl[N * 6];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < 3 * n; i++) {
    int x;
    cin >> x;
    pl[x] = 1;
  }
  Node rt;
  rt.cnt = rt.deg = 0;
  rt.pl = -1;
  rt.vis = 1;
  vector<Node> a{rt};
  stack<int> stk;
  stk.push(0);
  for (int i = 1; i <= n * 6; i++) {
    if (a[stk.top()].pl == pl[i]) {
      int tt = stk.top();
      a[tt].c[a[tt].cnt++] = i;
      if (a[tt].cnt == 3) stk.pop();
    } else {
      Node nd;
      nd.cnt = 1;
      nd.c[0] = i;
      nd.fa = stk.top();
      nd.deg = 0;
      nd.vis = 0;
      nd.pl = pl[i];
      a[stk.top()].deg++;
      stk.push(a.size());
      a.push_back(nd);
    }
  }
  for (int i = 1; i <= n * 2; i++) {
    int tt = -1;
    for (int j = 1; j <= n * 2; j++) {
      if (a[j].vis || a[j].pl != i % 2 || a[j].deg > 0) continue;
      tt = j;
      if (i % 2 || a[j].fa) break;
    }
    Node &nd = a[tt];
    cout << nd.c[0] << ' ' << nd.c[1] << ' ' << nd.c[2] << endl;
    nd.vis = 1;
    a[nd.fa].deg--;
  }
  return 0;
}
