#include <bits/stdc++.h>
using namespace std;
struct Node {
  int cnt;
  int cards[3];
  int father;
  int deg;
  int player;
  bool used;
};
vector<Node> nodes;
stack<int> S;
int main() {
  int n, x;
  Node root;
  scanf("%d", &n);
  vector<int> player(6 * n + 1, 0);
  for (int i = 0; i < 3 * n; i++) {
    scanf("%d", &x);
    player[x] = 1;
  }
  root.cnt = 0;
  root.deg = 0;
  root.player = -1;
  root.used = true;
  nodes.push_back(root);
  S.push(0);
  for (int i = 1; i <= 6 * n; i++) {
    if (nodes[S.top()].player == player[i]) {
      int it = S.top();
      nodes[it].cards[nodes[it].cnt++] = i;
      if (nodes[it].cnt == 3) S.pop();
    } else {
      Node X;
      X.cnt = 1;
      X.cards[0] = i;
      X.father = S.top();
      X.player = player[i];
      X.deg = 0;
      X.used = false;
      nodes[S.top()].deg++;
      S.push(nodes.size());
      nodes.push_back(X);
    }
  }
  for (int i = 1; i <= 2 * n; i++) {
    int choice = -1;
    for (int j = 1; j <= 2 * n; j++) {
      if (nodes[j].used or nodes[j].player != i % 2 or nodes[j].deg > 0)
        continue;
      choice = j;
      if (i % 2 or nodes[j].father != 0) break;
    }
    Node& X = nodes[choice];
    printf("%d %d %d\n", X.cards[0], X.cards[1], X.cards[2]);
    X.used = true;
    nodes[X.father].deg--;
  }
  return 0;
}
