#include <bits/stdc++.h>
using namespace std;
mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l, long long r) {
  return (mt_rnd_64() % (r - l + 1)) + l;
}
using ll = long long;
using ld = long double;
using ull = unsigned long long;
const double PI = acos(-1.0);
const ll mod = 1e9 + 9;
const ll INF = 1e13;
struct point {
  ld x, y, z;
};
ld sqr(ld a) { return a * a; }
ld len(point a, point b) {
  return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y) + sqr(a.z - b.z));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  vector<pair<ld, pair<ll, ll>>> lens;
  vector<point> p(n);
  for (auto &i : p) {
    cin >> i.x >> i.y >> i.z;
  }
  for (ll i = 0; i < n; ++i) {
    for (ll j = i + 1; j < n; ++j) {
      lens.push_back(make_pair(len(p[i], p[j]), make_pair(i, j)));
    }
  }
  sort(begin(lens), end(lens));
  vector<bool> was(n, 0);
  for (auto i : lens) {
    if (was[i.second.first] || was[i.second.second]) continue;
    was[i.second.first] = 1;
    was[i.second.second] = 1;
    cout << i.second.first + 1 << " " << i.second.second + 1 << "\n";
  }
  return 0;
}
