#include <bits/stdc++.h>
using namespace std;
const int N = 1210;
int n, st[N], tp, tt, bel[N], fa[N];
bool in[N], del[N], leaf[N], type[N];
tuple<int, int, int> dat[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1, x; i <= 3 * n; i++) cin >> x, in[x] = 1;
  for (int i = 1; i <= 6 * n; i++) {
    st[++tp] = i;
    if (tp >= 3 && in[st[tp - 2]] == in[st[tp - 1]] &&
        in[st[tp - 1]] == in[st[tp]]) {
      dat[++tt] = make_tuple(st[tp - 2], st[tp - 1], st[tp]);
      bel[st[tp - 2]] = bel[st[tp - 1]] = bel[st[tp]] = tt;
      type[tt] = in[st[tp]];
      tp -= 3;
      fa[tt] = st[tp];
    }
  }
  assert(!tp);
  for (int i = 1; i <= tt; i++) fa[i] = bel[fa[i]];
  for (int T = 1; T <= tt; T++) {
    memset(leaf, 1, sizeof(leaf));
    for (int i = 1; i <= tt; i++)
      if (!del[i]) leaf[fa[i]] = 0;
    int cnt = 0;
    for (int i = 1; i <= tt; i++)
      if (!del[i] && !fa[i] && !type[i]) ++cnt;
    for (int i = 1; i <= tt; i++)
      if (!del[i] && leaf[i] &&
          (((T & 1) && type[i]) ||
           (!(T & 1) && !type[i] && (cnt > 1 || T == tt || fa[i])))) {
        cout << get<0>(dat[i]) << ' ' << get<1>(dat[i]) << ' ' << get<2>(dat[i])
             << '\n';
        del[i] = 1;
        break;
      }
  }
  return 0;
}
