#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void cmin(T &a, T b) {
  ((a > b) && (a = b));
}
template <class T>
inline void cmax(T &a, T b) {
  ((a < b) && (a = b));
}
char IO;
template <class T = int>
T rd() {
  T s = 0;
  int f = 0;
  while (!isdigit(IO = getchar())) f |= IO == '-';
  do s = (s << 1) + (s << 3) + (IO ^ '0');
  while (isdigit(IO = getchar()));
  return f ? -s : s;
}
const int N = 1210, INF = 1e9 + 10;
int n;
struct Node {
  int k, a, b, c;
};
int A[N], S[N], I[N], T;
Node B[N];
int C;
int X[2][N], ind[N], R[2], F[N];
void Check(int i) {
  if (!ind[i]) X[B[i].k][++R[B[i].k]] = i;
}
int main() {
  n = rd() * 6;
  for (int i = 1, iend = n; i <= iend; ++i) A[i] = 1;
  for (int i = 1, iend = n / 2; i <= iend; ++i) A[rd()] = 0;
  for (int i = 1, iend = n; i <= iend; ++i) {
    S[++T] = i;
    I[T] = (T == 1 || A[S[T - 1]] != A[S[T]]) ? ++C : I[T - 1];
    if (T > 2 && A[S[T]] == A[S[T - 1]] && A[S[T]] == A[S[T - 2]]) {
      int u = I[T];
      B[u] = (Node){A[S[T]], S[T - 2], S[T - 1], S[T]};
      ind[F[u] = I[T -= 3]]++;
    }
  }
  for (int i = 1, iend = C; i <= iend; ++i) Check(i);
  for (int i = 1, iend = n / 6; i <= iend; ++i) {
    for (int j = 0, jend = 1; j <= jend; ++j) {
      if (!F[X[1][R[1]]]) swap(X[1][R[1]], X[1][1]);
      int u = X[j][R[j]--];
      printf("%d %d %d\n", B[u].a, B[u].b, B[u].c);
      if (F[u]) --ind[F[u]], Check(F[u]);
    }
  }
}
