#include <bits/stdc++.h>
using namespace std;
struct Node {
  vector<int> cards;
  Node* par;
  int deg;
  int player;
};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n;
  cin >> n;
  vector<bool> player(n * 6 + 1);
  for (int i = 0; i < 3 * n; ++i) {
    int x;
    cin >> x;
    player[x] = true;
  }
  Node* root = new Node();
  root->deg = 0, root->player = -1;
  vector<Node*> nodes;
  vector<Node*> stack;
  stack.push_back(root);
  for (int i = 1; i <= 6 * n; ++i) {
    if (stack.back()->player == player[i]) {
      stack.back()->cards.push_back(i);
      if (stack.back()->cards.size() == 3) stack.pop_back();
    } else {
      Node* X = new Node();
      X->cards.push_back(i);
      X->par = stack.back();
      X->player = player[i];
      ++stack.back()->deg;
      stack.push_back(X);
      nodes.push_back(X);
    }
  }
  for (int i = 1; i <= 2 * n; ++i) {
    int choice = -1;
    for (int j = 0; j < nodes.size(); ++j) {
      Node* node = nodes[j];
      if (node->player != i % 2 || node->deg > 0) continue;
      choice = j;
      if (i % 2 || node->par != root) break;
    }
    for (auto j : nodes[choice]->cards) cout << j << " ";
    --nodes[choice]->par->deg;
    nodes.erase(nodes.begin() + choice);
    cout << '\n';
  }
}
