#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
struct Point {
  int first, second, z;
  int ind;
  Point(){};
};
bool operator<(Point& p1, Point& p2) {
  if (p1.first != p2.first)
    return p1.first < p2.first;
  else if (p1.second != p2.second)
    return p1.second < p2.second;
  else
    return p1.z < p2.z;
}
int main() {
  int n;
  cin >> n;
  vector<Point> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second >> a[i].z;
    a[i].ind = i;
  }
  vector<bool> b(n, false);
  for (int i = 0; i < n; i++)
    if (!b[i]) {
      b[i] = true;
      long double mn = 1e18;
      int l = n;
      for (int j = i + 1; j < n; j++) {
        if (!b[j]) {
          long double dx = a[i].first - a[j].first,
                      dy = a[i].second - a[j].second, dz = a[i].z - a[j].z;
          long double cur = dx * dx + dy * dy + dz * dz;
          if (cur < mn) {
            mn = cur;
            l = j;
          }
        }
      }
      b[l] = true;
      cout << i + 1 << ' ' << l + 1 << endl;
    }
}
