#include <bits/stdc++.h>
struct point {
  long long x, y, z, id;
};
long long volume(point &a, point &b) {
  return std::abs((a.x - b.x) * (a.y - b.y) * (a.z - b.z));
}
bool is_in(point b1, point b2, point t) {
  bool x = std::min(b1.x, b2.x) <= t.x && t.x <= std::max(b1.x, b2.x);
  bool y = std::min(b1.y, b2.y) <= t.y && t.y <= std::max(b1.y, b2.y);
  bool z = std::min(b1.z, b2.z) <= t.z && t.z <= std::max(b1.z, b2.z);
  return x && y && z;
}
void print(std::vector<point> a) {
  for (auto p : a) {
    std::cout << p.id << ' ';
  }
  std::cout << '\n';
}
int main() {
  ;
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  int n;
  std::cin >> n;
  point t;
  std::vector<point> v(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> t.x >> t.y >> t.z;
    t.id = i + 1;
    v[i] = t;
  }
  while (v.size() > 2) {
    point p1 = v[0], p2 = v[1];
    auto p1i = v.begin();
    auto p2i = std::next(p1i);
    bool second_first = true;
    for (auto it = std::next(p2i); it != v.end(); ++it) {
      if (is_in(p1, p2, *it)) {
        if (volume(p1, *it) > volume(p2, *it)) {
          p1 = *it;
          p1i = it;
          second_first = false;
        } else {
          p2 = *it;
          p2i = it;
          second_first = true;
        }
      }
    }
    std::cout << p1i->id << ' ' << p2i->id << '\n';
    if (second_first) {
      v.erase(p2i);
      v.erase(p1i);
    } else {
      v.erase(p1i);
      v.erase(p2i);
    }
  }
  std::cout << v[0].id << ' ' << v[1].id;
  ;
  ;
  return 0;
  ;
}
