#include <bits/stdc++.h>
using namespace std;
int sk[5005][3], a[5005], son[5005][3], tot, sl[5005], fa[5005], id[5005],
    mk[5005], us[5005], dep[5005];
int main() {
  int n, r = 0;
  scanf("%d", &n);
  for (int i = 1, x; i <= 3 * n; ++i) scanf("%d", &x), a[x] = 1;
  for (int i = 1; i <= 6 * n; ++i) {
    if (!r || a[sk[r][0]] != a[i])
      sk[++r][0] = i, sl[r] = 1, id[r] = ++tot;
    else {
      sk[r][sl[r]++] = i;
      if (sl[r] == 3) {
        int x = id[r];
        fa[x] = id[r - 1];
        for (int j = 0; j < 3; ++j) son[x][j] = sk[r][j];
        --r;
        mk[x] = a[son[x][0]];
      }
    }
  }
  int sz = 0;
  for (int i = 1; i <= tot; ++i) {
    if (fa[i] == 0 && !mk[i]) ++sz;
    dep[fa[i]]++;
  }
  for (int i = 1; i <= 2 * n; ++i) {
    int s = i & 1;
    for (int j = 1; j <= tot; ++j)
      if (mk[j] == s && !us[j] && dep[j] == 0) {
        if (i < 2 * n && s == 0 && sz == 1 && fa[j] == 0) continue;
        us[j] = 1;
        dep[fa[j]]--;
        if (fa[j] == 0 && mk[j] == 0) --sz;
        printf("%d %d %d\n", son[j][0], son[j][1], son[j][2]);
        break;
      }
  }
}
