#include <bits/stdc++.h>
using namespace std;
int x[10010], y[10010], z[10010], type[10010], q[10010], vis[10010], p[10010],
    fa[10010], use[10010], a[10010], v[10010];
int main() {
  int i, n, top = 0, j, h = 0;
  scanf("%d", &n);
  for (i = 1; i <= n * 3; i++) {
    scanf("%d", &a[i]);
    vis[a[i]] = 1;
  }
  int tot = 0;
  for (i = 1; i <= n * 6; i++) {
    if (top >= 2 && vis[q[top]] == vis[q[top - 1]] && vis[i] == vis[q[top]]) {
      tot++;
      x[tot] = q[top - 1];
      y[tot] = q[top];
      z[tot] = i;
      type[tot] = vis[i];
      p[q[top - 1]] = tot;
      for (j = q[top - 1] + 1; j < i; j++)
        if (p[j]) {
          fa[p[j]] = tot;
          use[tot]++;
          p[j] = 0;
        }
      top = top - 2;
    } else {
      q[++top] = i;
    }
  }
  for (i = 1; i <= tot; i++) {
    if (fa[i] == 0 && type[i] == 0) h++;
  }
  int q = tot, t = 1;
  while (q--) {
    int u = 0;
    for (i = 1; i <= tot; i++)
      if (use[i] == 0 && !v[i] && type[i] == t &&
          (h != 1 || type[i] || fa[i] || q == 0)) {
        u = i;
        break;
      }
    v[u] = 1;
    if (!fa[u] && !type[u]) h--;
    use[fa[u]]--;
    printf("%d %d %d\n", x[u], y[u], z[u]);
    t ^= 1;
  }
}
