#include <bits/stdc++.h>
using namespace std;
inline int rd() {
  int x = 0;
  char c = getchar();
  bool f = 0;
  while (c < '0' && c != '-') c = getchar();
  if (c == '-') f = 1, c = getchar();
  while (c >= '0') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return f ? -x : x;
}
const int SIZE = 200 * 6 + 10;
int n;
int stk[SIZE], tp, sz[SIZE];
bool mark[SIZE];
int deg[SIZE], fa[SIZE];
bool vis[SIZE];
int ans[SIZE][3];
void _main() {
  n = rd();
  for (register int i = 1, _n = 3 * n; i <= _n; ++i) mark[rd()] = 1;
  int F;
  for (register int i = 1, _n = 6 * n; i <= _n; ++i) {
    if (tp && mark[stk[tp]] == mark[i]) {
      ans[stk[tp]][sz[stk[tp]]++] = i;
      if (sz[stk[tp]] == 3) --tp;
    } else {
      stk[++tp] = i;
      sz[i] = 1;
      fa[i] = stk[tp - 1];
      ++deg[fa[i]];
    }
  }
  for (register int t = 1, _n = 2 * n; t <= _n; ++t) {
    int x = 0, y = 0;
    for (register int i = 1, _n = 6 * n; i <= _n; ++i)
      if (mark[i] == (t & 1) && sz[i] && deg[i] == 0 && !vis[i]) {
        if (fa[i])
          x = i;
        else
          y = i;
      }
    if (x) {
      printf("%d %d %d\n", x, ans[x][1], ans[x][2]);
      --deg[fa[x]];
      vis[x] = 1;
    } else
      printf("%d %d %d\n", y, ans[y][1], ans[y][2]), vis[y] = 1;
  }
}
int main() {
  _main();
  return 0;
}
