#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const long long mod = 1e9 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long qmul(long long a, long long b) {
  long long r = 0;
  while (b) {
    if (b & 1) r = (r + a) % mod;
    b >>= 1;
    a = (a + a) % mod;
  }
  return r;
}
long long qpow(long long a, long long n) {
  long long r = 1;
  while (n) {
    if (n & 1) r = (r * a) % mod;
    n >>= 1;
    a = (a * a) % mod;
  }
  return r;
}
long long qpow(long long a, long long n, long long p) {
  long long r = 1;
  while (n) {
    if (n & 1) r = (r * a) % p;
    n >>= 1;
    a = (a * a) % p;
  }
  return r;
}
const int N = 2e5 + 10;
struct node {
  long long x, y, z;
} a[N];
int st[N];
long long dist(node A, node B) {
  return abs(A.x - B.x) + abs(A.y - B.y) + abs(A.z - B.z);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    cin >> a[i].x >> a[i].y >> a[i].z;
  }
  memset(st, 0, sizeof(st));
  int id = -1;
  for (int i = (1); i <= (n); i++) {
    if (st[i]) continue;
    long long maxx = 0x3f3f3f3f;
    id = -1;
    for (int j = (1); j <= (n); j++) {
      if (j == i || st[j] == 1) continue;
      if (dist(a[i], a[j]) < maxx) {
        maxx = dist(a[i], a[j]);
        id = j;
      }
    }
    st[i] = 1;
    st[id] = 1;
    cout << i << " " << id << endl;
  }
  return 0;
}
