#include <bits/stdc++.h>
using namespace std;
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 2e3 + 9, OO = 1e9 + 7, MOD = 998244353;
const long long inf = 1e18;
vector<pair<pair<int, int>, pair<int, int>>> vec;
bool vis[N];
int main() {
  cout << fixed << setprecision(2), ios::sync_with_stdio(false),
      cin.tie(nullptr), cout.tie(nullptr);
  int n, a, b, c;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b >> c;
    vec.push_back({{a, b}, {c, i + 1}});
  }
  sort(((vec).begin()), ((vec).end()));
  n = vec.size();
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    int x = vec[i].first.first, y = vec[i].first.second,
        z = vec[i].second.first;
    int x2 = vec[i].first.first, y2 = vec[i].first.second,
        z2 = vec[i].second.first;
    for (int j = i + 1; j < n; ++j) {
      if (vis[j]) continue;
      x = vec[i].first.first, y = vec[i].first.second, z = vec[i].second.first;
      x2 = vec[i].first.first, y2 = vec[i].first.second,
      z2 = vec[i].second.first;
      x = min(x, vec[j].first.first), y = min(y, vec[j].first.second),
      z = min(z, vec[j].second.first);
      x2 = max(x2, vec[j].first.first), y2 = max(y2, vec[j].first.second),
      z2 = max(z2, vec[j].second.first);
      bool found = 1;
      for (int k = i + 1; k < n; ++k) {
        if (k == j || vis[k]) continue;
        int a = vec[k].first.first, b = vec[k].first.second,
            c = vec[k].second.first;
        if ((a >= x && a <= x2) && (b >= y && b <= y2) && (c >= z && c <= z2)) {
          found = 0;
          break;
        }
      }
      if (found) {
        vis[i] = 1;
        vis[j] = 1;
        cout << vec[i].second.second << ' ' << vec[j].second.second << '\n';
        break;
      }
    }
  }
  return 0;
}
