#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 314;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);
int used[N];
long long x[N], y[N], z[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> z[i];
  }
  for (int i = 0; i < n; ++i) {
    if (used[i]) continue;
    int ind = -1;
    long double mini = INF;
    for (int j = 0; j < n; ++j) {
      if (used[j] || i == j) continue;
      double dl =
          sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) +
               (z[i] - z[j]) * (z[i] - z[j]));
      if (dl < mini) {
        mini = dl;
        ind = j;
      }
    }
    used[i] = used[ind] = 1;
    cout << i + 1 << " " << ind + 1 << "\n";
  }
}
