#include <bits/stdc++.h>
using namespace std;
void optimise() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
long long int inf = 1000000000000000000;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> x(n + 1);
  vector<long long int> y(n + 1);
  vector<long long int> z(n + 1);
  set<long long int> s;
  for (long long int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i] >> z[i];
    s.insert(i);
  }
  while (!s.empty()) {
    auto i = s.begin();
    auto j = i;
    j++;
    long long int min1 = inf;
    long long int f;
    for (; j != s.end(); j++) {
      long long int dis = (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 (dis < min1) {
        min1 = dis;
        f = *j;
      }
    }
    cout << *i << " " << f << endl;
    s.erase(i);
    s.erase(f);
  }
}
signed main() {
  optimise();
  long long int t;
  t = 1;
  while (t--) {
    solve();
    cout << endl;
  }
}
