#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n + 1][3];
  map<long long, long long> m;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  vector<pair<double, pair<long long, long long> > > v;
  for (long long i = 1; i < n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      double d =
          sqrt(pow(abs(a[i][0] - a[j][0]), 2) + pow(abs(a[i][1] - a[j][1]), 2) +
               pow(abs(a[i][2] - a[j][2]), 2));
      v.push_back({d, {i, j}});
    }
  }
  sort(v.begin(), v.end());
  long long c = 0;
  for (long long i = 0; i < v.size(); i++) {
    if (m[(v[i].second).second] == 0 && m[(v[i].second).first] == 0) {
      cout << (v[i].second).second << " " << (v[i].second).first << endl;
      m[(v[i].second).second]++;
      m[(v[i].second).first]++;
      c++;
    }
    if (c == n / 2) break;
  }
}
