#include <bits/stdc++.h>
using namespace std;
struct points {
  long long x, y, z, id;
};
struct disid {
  long long id1, id2, dist;
};
bool check(vector<points>& v, long long i, long long j, long long save) {
  if ((v[save].x > max(v[i].x, v[j].x)) || (v[save].x < min(v[i].x, v[j].x))) {
    return true;
  }
  if ((v[save].y > max(v[i].y, v[j].y)) || (v[save].y < min(v[i].y, v[j].y))) {
    return true;
  }
  if ((v[save].z > max(v[i].z, v[j].z)) || (v[save].z < min(v[i].z, v[j].z))) {
    return true;
  }
  return false;
}
bool cmp(disid a, disid b) {
  if (a.dist < b.dist) {
    return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<points> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i].x >> v[i].y >> v[i].z;
    v[i].id = i + 1;
  }
  vector<disid> ans;
  map<long long, long long> mark;
  for (long long i = 0; i < n; i++) {
    if (mark[v[i].id] == 1) {
      continue;
    }
    long long dist = 1e18;
    long long save = 1;
    for (long long j = 0; j < n; j++) {
      if (i == j) {
        continue;
      }
      if (mark[v[j].id] == 1) {
        continue;
      }
      long long dist1 = (abs(v[i].x - v[j].x) * abs(v[i].x - v[j].x)) +
                        (abs(v[i].y - v[j].y) * abs(v[i].y - v[j].y)) +
                        (abs(v[i].z - v[j].z) * abs(v[i].z - v[j].z));
      if (dist1 < dist) {
        dist = dist1;
        save = j;
      }
    }
    disid a;
    a.id1 = v[i].id, a.id2 = v[save].id, a.dist = dist;
    mark[v[i].id] = 1;
    mark[v[save].id] = 1;
    ans.push_back(a);
  }
  for (long long i = 0; i < ans.size(); i++) {
    cout << ans[i].id1 << " " << ans[i].id2 << " " << endl;
  }
  return 0;
}
