#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 5;
const int inf = 0x3f3f3f3f;
const int modu = 1e9 + 7;
vector<int> part[maxn];
int d[maxn], n, son[maxn], far[maxn];
bool player[maxn];
bool vis[maxn];
stack<vector<int> > st;
int main() {
  cin >> n;
  memset(player, 0, sizeof(player));
  memset(son, 0, sizeof(son));
  memset(far, -1, sizeof(far));
  memset(vis, 0, sizeof(vis));
  int tot = 0;
  for (int i = 0; i < 3 * n; ++i) {
    int x;
    scanf("%d", &x);
    player[x] = 1;
  }
  for (int i = 1; i <= 6 * n; ++i) {
    if (st.empty() || player[st.top()[0]] != player[i]) {
      st.push(vector<int>(1, i));
    } else {
      st.top().push_back(i);
      if (st.top().size() == 3) {
        part[tot] = st.top();
        int tmp = st.top()[0];
        d[tot] = tmp;
        tot++;
        st.pop();
        if (!st.empty()) {
          far[tmp] = st.top()[0];
          son[st.top()[0]]++;
        }
      }
    }
  }
  int cur = 0;
  for (int i = 0; i < 2 * n; ++i) {
    int k = -1;
    cur ^= 1;
    for (int j = 0; j < tot; ++j)
      if (!vis[j] && son[d[j]] == 0 && player[d[j]] == cur &&
          (k == -1 || far[d[k]] == -1 ||
           (far[d[k]] >= 0 && far[d[j]] >= 0 &&
            son[far[d[k]]] > son[far[d[j]]]))) {
        k = j;
      }
    vis[k] = true;
    for (int j = 0; j < 3; ++j) printf("%d ", part[k][j]);
    printf("\n");
    if (far[d[k]] >= 0) son[far[d[k]]]--;
  }
  return 0;
}
