#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1210;
struct Node {
  int a, b, c, fa;
  bool first;
};
bool z[MAXN];
int out[MAXN];
Node x[MAXN];
int p[MAXN];
tuple<int, int, int> Get3(stack<int>& s) {
  int a = s.top();
  s.pop();
  int b = s.top();
  s.pop();
  int c = s.top();
  s.pop();
  if (a > b) swap(a, b);
  if (a > c) swap(a, c);
  if (b > c) swap(b, c);
  return {a, b, c};
}
void Rebuild(stack<int>& s, int& fn, int& sn) {
  fn = sn = 0;
  stack<int> t;
  for (int i = 0; i < 3; ++i) {
    if (s.empty()) break;
    t.push(s.top());
    s.pop();
  }
  while (!t.empty()) {
    int a = t.top();
    t.pop();
    s.push(a);
    if (z[a]) {
      ++fn;
      sn = 0;
    } else {
      ++sn;
      fn = 0;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < 3 * n; ++i) {
    int a;
    cin >> a;
    z[a] = true;
  }
  stack<int> s;
  int fn = 0, sn = 0;
  for (int i = 1; i <= 6 * n; ++i) {
    s.push(i);
    if (z[i]) {
      ++fn;
      sn = 0;
    } else {
      ++sn;
      fn = 0;
    }
    while (fn == 3 || sn == 3) {
      auto [a, b, c] = Get3(s);
      Node t{a, b, c, -1, fn == 3};
      if (!s.empty()) {
        t.fa = s.top();
        ++out[t.fa];
      }
      x[a] = t;
      p[a] = p[b] = p[c] = a;
      Rebuild(s, fn, sn);
    }
  }
  while (!s.empty()) {
    auto [a, b, c] = Get3(s);
    fn = z[a] + z[b] + z[c];
    Node t{a, b, c, -1, fn == 3};
    x[a] = t;
    p[a] = p[b] = p[c] = a;
  }
  for (int i = 1; i <= 6 * n; ++i) {
    if (p[i] == i) continue;
    out[p[i]] += out[i];
    out[i] = 0;
  }
  vector<Node> first, second;
  for (int i = 1; i <= 6 * n; ++i) {
    if (x[i].fa != 0 && out[i] == 0) {
      if (x[i].first) {
        first.push_back(x[i]);
      } else {
        second.push_back(x[i]);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    Node t = first.back();
    first.pop_back();
    cout << t.a << " " << t.b << " " << t.c << endl;
    if (t.fa != -1) {
      int fa = p[t.fa];
      --out[fa];
      if (out[fa] == 0) {
        if (x[fa].first) {
          first.push_back(x[fa]);
        } else {
          second.push_back(x[fa]);
        }
      }
    }
    bool flag = true;
    vector<Node>::iterator iter;
    for (iter = second.begin(); iter != second.end(); ++iter) {
      if (i != n && iter->fa == -1 && flag) {
        flag = false;
        continue;
      }
      break;
    }
    if (iter == second.end()) iter = second.begin();
    t = *iter;
    second.erase(iter);
    cout << t.a << " " << t.b << " " << t.c << endl;
    if (t.fa != -1) {
      int fa = p[t.fa];
      --out[fa];
      if (out[fa] == 0) {
        if (x[fa].first) {
          first.push_back(x[fa]);
        } else {
          second.push_back(x[fa]);
        }
      }
    }
  }
  return 0;
}
