#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y, z;
  point() {}
  point(long long a, long long b, long long c) : x(a), y(b), z(c) {}
  double operator()(point y) {
    return sqrt((this->x - y.x) * (this->x - y.x) +
                (this->y - y.y) * (this->y - y.y) +
                (this->z - y.z) * (this->z - y.z));
  }
};
vector<pair<int, int>> ans;
int taken[10005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long a, b, c;
  point arr[n];
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    point p(a, b, c);
    arr[i] = p;
  }
  for (int i = 0; i < n; i++) {
    double minimum = 1e11;
    int correct;
    if (taken[i]) continue;
    for (int j = 0; j < n; j++) {
      if (i == j || taken[j]) continue;
      double x = arr[i](arr[j]);
      if (x < minimum) {
        minimum = x;
        correct = j;
      }
    }
    taken[correct] = 1;
    taken[i] = 1;
    ans.push_back({i, correct});
  }
  for (int i = 0; i < n / 2; i++)
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
  return 0;
}
