#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
struct node {
  long long x, y, z;
  int id;
} a[20005];
int vis[20005];
double fun(int i, int j) {
  double x1 = a[i].x, x2 = a[j].x;
  double y1 = a[i].y, y2 = a[j].y;
  double z1 = a[i].z, z2 = a[j].z;
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) +
              (z1 - z2) * (z1 - z2));
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld%lld", &a[i].x, &a[i].y, &a[i].z);
    a[i].id = i;
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    double mdis = 1e18;
    int pos = 0;
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (vis[j]) continue;
      double dis = fun(i, j);
      if (dis < mdis) {
        mdis = dis;
        pos = j;
      }
    }
    printf("%d %d\n", i, pos);
    vis[i] = vis[pos] = 1;
  }
  return 0;
}
