#include <bits/stdc++.h>
using namespace std;
class Point {
 public:
  Point(int idx, long long x, long long y, long long z)
      : idx(idx), x(x), y(y), z(z) {
    dist = x * x + y * y + z * z;
  };
  int idx;
  long long x, y, z;
  long long dist;
  bool operator<(const Point& p) { return dist < p.dist; }
};
int visited[50009] = {
    0,
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<Point> v;
  for (int i = 1; i <= n; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    v.emplace_back(i, x, y, z);
  }
  for (int i = 0; i < n; i++) {
    if (visited[i]) {
      continue;
    }
    long long mindist = LLONG_MAX - 1;
    int minIdx = 0;
    for (int j = i + 1; j < n; j++) {
      if (visited[j]) continue;
      long long d = ((v[i].x - v[j].x) * (v[i].x - v[j].x) +
                     (v[i].y - v[j].y) * (v[i].y - v[j].y) +
                     (v[i].z - v[j].z) * (v[i].z - v[j].z));
      if (mindist > d) {
        mindist = d;
        minIdx = j;
      }
    }
    visited[i] = 1;
    visited[minIdx] = 1;
    cout << i + 1 << ' ' << minIdx + 1 << '\n';
  }
  return 0;
}
