#include <bits/stdc++.h>
using namespace std;
int OO = (int)1e9;
int const N = 1e5 + 10;
long long x[N], y[N], z[N];
int vis[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin.exceptions(cin.failbit);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }
  vector<pair<int, int> > Ans;
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    vis[i] = 1;
    vector<pair<long long, long long> > v;
    for (int j = 0; j < n; j++) {
      if (!vis[j]) {
        long long dis = (x[i] - x[j]) * (x[i] - x[j]) +
                        (y[i] - y[j]) * (y[i] - y[j]) +
                        (z[i] - z[j]) * (z[i] - z[j]);
        v.emplace_back(dis, j);
      }
    }
    sort((v).begin(), (v).end());
    vis[v[0].second] = 1;
    Ans.emplace_back(i, v[0].second);
  }
  for (pair<int, int> p : Ans)
    cout << p.first + 1 << " " << p.second + 1 << endl;
}
