#include <bits/stdc++.h>
using namespace std;
const int mxn = 1201;
int n, m;
int a[mxn], d[mxn], p[mxn], vis[mxn];
vector<int> v[mxn];
stack<int> stk;
auto cmp = [](int x, int y) { return p[x] < p[y]; };
typedef priority_queue<int, vector<int>, decltype(cmp)> PQ;
PQ pq[2] = {PQ(cmp), PQ(cmp)};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < 3 * n; i++) {
    int x;
    cin >> x;
    a[x] = 1;
  }
  a[0] = -1;
  v[m].push_back(0);
  stk.push(m++);
  for (int i = 1; i <= 6 * n; i++) {
    int x = stk.top();
    if (a[v[x][0]] == a[i]) {
      v[x].push_back(i);
      if (v[x].size() == 3) stk.pop();
    } else {
      d[p[m] = x]++;
      v[m].push_back(i);
      stk.push(m++);
    }
  }
  for (int i = 1; i <= 2 * n; i++)
    if (!d[i]) pq[a[v[i][0]]].push(i);
  for (int i = 1; i <= 2 * n; i++) {
    int x = pq[i & 1].top();
    pq[i & 1].pop();
    vis[x] = 1;
    if (!--d[p[x]] && p[x]) pq[!(i & 1)].push(p[x]);
    cout << v[x][0] << " " << v[x][1] << " " << v[x][2] << '\n';
  }
  return 0;
}
