#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  vector<vector<long double> > dist(n + 1, vector<long double>(n + 1));
  vector<long double> x(n + 1), y(n + 1), z(n + 1);
  vector<long long int> vis(n + 1, 0);
  for (long long int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> z[i];
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= n; j++) {
      dist[i][j] = (x[i] - x[j]) * (x[i] - x[j]) +
                   (y[i] - y[j]) * (y[i] - y[j]) +
                   (z[i] - z[j]) * (z[i] - z[j]);
      dist[i][j] = sqrt(dist[i][j]);
    }
  }
  for (long long int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      long double big = 1e18 * 1.0;
      long long int ans;
      for (long long int j = i + 1; j <= n; j++) {
        if (vis[j] == 0) {
          if (dist[i][j] < big) {
            big = dist[i][j];
            ans = j;
          }
        }
      }
      vis[ans] = 1;
      vis[i] = 1;
      cout << i << " " << ans << '\n';
    }
  }
  return 0;
}
