#include <bits/stdc++.h>
using namespace std;
vector<int> E[2005];
int bln[2005];
int cnt[2005];
vector<int> num[2005];
void solve() {
  int n;
  scanf("%d", &n);
  int ok[2005];
  fill(ok, ok + 2005, 0);
  for (int i = 0; i < 3 * n; i++) {
    int first;
    scanf("%d", &first);
    ok[first]++;
  }
  vector<pair<int, int> > v;
  for (int i = 1; i <= n * 6; i++) {
    if (v.size() >= 2) {
      if (v.back().second == ok[i] && v[v.size() - 2].second == ok[i]) {
        int first = v.back().first;
        v.pop_back();
        int x2 = v.back().first;
        v.pop_back();
        bln[i] = x2;
        bln[first] = x2;
        bln[x2] = x2;
        num[x2].push_back(i);
        num[x2].push_back(first);
        num[x2].push_back(x2);
        continue;
      }
    }
    v.push_back(make_pair(i, ok[i]));
  }
  for (int i = 1; i <= n * 6; i++) {
    if (v.size() >= 2) {
      if (v.back().second == ok[i] && v[v.size() - 2].second == ok[i]) {
        int first = v.back().first;
        v.pop_back();
        int x2 = v.back().first;
        v.pop_back();
        if (v.size()) {
          E[x2].push_back(bln[v.back().first]);
          cnt[bln[v.back().first]]++;
        }
        continue;
      }
    }
    v.push_back(make_pair(i, ok[i]));
  }
  priority_queue<pair<int, int> > q1, q2;
  for (int i = 1; i <= n * 6; i++) {
    if (bln[i] == i && cnt[i] == 0) {
      if (ok[i] == 1)
        q1.push(make_pair(E[i].size(), i));
      else
        q2.push(make_pair(E[i].size(), i));
    }
  }
  for (int i = 0; i < n; i++) {
    if (q1.size() == 0) {
      printf("NO\n");
      return;
    }
    int first = q1.top().second;
    q1.pop();
    sort(num[first].begin(), num[first].end());
    for (auto it : num[first]) {
      printf("%d ", it);
    }
    printf("\n");
    for (auto it : E[first]) {
      if (--cnt[it] == 0) {
        if (ok[it] == 1)
          q1.push(make_pair(E[it].size(), it));
        else
          q2.push(make_pair(E[it].size(), it));
      }
    }
    assert(q2.size());
    first = q2.top().second;
    q2.pop();
    sort(num[first].begin(), num[first].end());
    for (auto it : num[first]) {
      printf("%d ", it);
    }
    printf("\n");
    for (auto it : E[first]) {
      if (--cnt[it] == 0) {
        if (ok[it] == 1)
          q1.push(make_pair(E[it].size(), it));
        else
          q2.push(make_pair(E[it].size(), it));
      }
    }
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
