#include <bits/stdc++.h>
using namespace std;
int gcdEx(int a, int b, int *x, int *y) {
  if (!a) {
    *x = 0;
    *y = 1;
    return b;
  }
  int x1, y1, gcd = gcdEx(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
int modI(int b, int m) {
  int x, y;
  gcdEx(b, m, &x, &y);
  return (x % m + m) % m;
}
long long modP(long long x, long long y) {
  long long r = 1;
  x %= 1000000007;
  while (y > 0) {
    if (y & 1) {
      r = (r * x) % 1000000007;
    }
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return r;
}
int VERBOSE = 0;
void code() {
  int n;
  cin >> n;
  long long x[n], y[n], z[n];
  for (int i = 0; i < (n); ++i) cin >> x[i] >> y[i] >> z[i];
  int rem[n];
  memset(rem, 0, sizeof(rem));
  double sd, d;
  int sdj;
  for (int i = 0; i < (n); ++i) {
    if (rem[i]) continue;
    sd = 1e9;
    for (int j = 1 + i; j <= (n - 1); ++j) {
      if (rem[j]) continue;
      d = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) +
               (z[i] - z[j]) * (z[i] - z[j]));
      if (d < sd) {
        sd = d;
        sdj = j;
      }
    }
    cout << (i + 1) << " " << (sdj + 1) << "\n";
    rem[sdj] = 1;
    rem[i] = 1;
  }
}
int main(int argc, char *argv[]) {
  if (argc == 2 && argv[1][1] == 'v') {
    VERBOSE = 1;
  }
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  code();
  return 0;
}
