#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<long long int, long long int>,
            pair<long long int, long long int> > >
    points;
bool rem[100000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int TESTS, a, b, c, n, p, w, d, m, x, i, y, z;
  TESTS = 1;
  while (TESTS--) {
    cin >> n;
    for (long long int i = 0; i <= n - 1; i++) {
      cin >> x >> y >> z;
      points.push_back(make_pair(make_pair(x, y), make_pair(z, i)));
      rem[i] = false;
    }
    for (long long int i = 0; i <= n - 1; i++) {
      if (rem[i]) continue;
      long long int dif = 100000000000;
      long long int minj = -1;
      for (long long int j = 0; j <= n - 1; j++) {
        if (rem[j] || i == j) continue;
        if (abs(points[i].first.first - points[j].first.first) +
                abs(points[i].first.second - points[j].first.second) +
                abs(points[i].second.first - points[j].second.first) <
            dif) {
          dif = abs(points[i].first.first - points[j].first.first) +
                abs(points[i].first.second - points[j].first.second) +
                abs(points[i].second.first - points[j].second.first);
          minj = j;
        }
      }
      rem[i] = true;
      rem[minj] = true;
      cout << i + 1 << " " << minj + 1 << "\n";
    }
  }
  return 0;
}
