#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
const long long MOD2 = (long long)1000000007 * (long long)1000000007;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
vector<int> gps[1202], ans;
int cnt, col[(1235)], pa[(1235)], d[(1235)], cs[(1235)];
bool vis[1222];
void fmain(int tid) {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n + n + n); (i)++) {
    scanf("%d", &k);
    vis[k] = 1;
  }
  vector<int> stk;
  for (int(i) = 1; (i) <= (int)(n * 6); (i)++) {
    int w = vis[i];
    if (stk.empty() || col[stk.back()] != w) {
      ++cnt;
      col[cnt] = w;
      int fa = stk.empty() ? 0 : stk.back();
      pa[cnt] = fa;
      d[cnt] = d[fa] + 1;
      cs[fa]++;
      gps[cnt].push_back(i);
      stk.push_back(cnt);
    } else {
      int id = stk.back();
      gps[id].push_back(i);
      if (gps[id].size() == 3) {
        stk.pop_back();
      }
    }
  }
  assert(stk.empty() && cnt == n + n);
  priority_queue<pair<int, int> > qs[2];
  for (int(i) = 1; (i) <= (int)(cnt); (i)++)
    if (cs[i] == 0) qs[col[i]].push({d[i], i});
  for (int(i) = 1; (i) <= (int)(cnt); (i)++) {
    int who = (i & 1);
    assert(!qs[who].empty());
    int x = qs[who].top().second;
    qs[who].pop();
    ans.push_back(x);
    if (pa[x]) {
      int y = pa[x];
      cs[y]--;
      if (cs[y] == 0) {
        qs[col[y]].push({d[y], y});
      }
    }
  }
  for (int(i) = 0; (i) < (int)(cnt); (i)++) {
    int id = ans[i];
    printf("%d %d %d\n", gps[id][0], gps[id][1], gps[id][2]);
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
