#include <bits/stdc++.h>
int read() {
  static int c, x;
  while ((c = getchar()) < 48) {
  }
  x = c & 15;
  while ((c = getchar()) >= 48) x = x * 10 + (c & 15);
  return x;
}
bool vis[210 * 6];
bool col[210 * 2];
int q0[210], q1[210];
int stk[210 * 2], deg[210 * 2], fa[210 * 2];
int p0[210 * 2], p1[210 * 2], p2[210 * 2];
int main() {
  const int n = read();
  for (int i = n * 3; i--;) vis[read()] = true;
  for (int i = 1, cnt = 0, top = 0; i <= n * 6; ++i) {
    if (top && col[stk[top]] == vis[i]) {
      if (!p1[stk[top]]) {
        p1[stk[top]] = i;
      } else {
        p2[stk[top--]] = i;
      }
      continue;
    }
    stk[++top] = ++cnt;
    col[cnt] = vis[i];
    fa[cnt] = stk[top - 1];
    ++deg[fa[cnt]];
    p0[cnt] = i;
  }
  int t0 = 0, t1 = 0;
  for (int i = 1; i <= n * 2; ++i) {
    if (!deg[i]) {
      if (col[i]) {
        q1[++t1] = i;
      } else {
        q0[++t0] = i;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!fa[q1[i]]) std::swap(q1[i], q1[t1]);
    printf("%d %d %d\n", p0[q1[i]], p1[q1[i]], p2[q1[i]]);
    if (!--deg[fa[q1[i]]]) q0[++t0] = fa[q1[i]];
    if (!fa[q0[i]]) std::swap(q0[i], q0[t0]);
    printf("%d %d %d\n", p0[q0[i]], p1[q0[i]], p2[q0[i]]);
    if (!--deg[fa[q0[i]]]) q1[++t1] = fa[q0[i]];
  }
  return 0;
}
