#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
struct PLAT
{
int index;
int h;
int x1;
int x2;
};
struct PLAT plat[1003];
int p2[1003];
int n;
bool cmp(PLAT a, PLAT b)
{
return a.h >= b.h;
}
int main()
{
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> plat[i].h >> plat[i].x1 >> plat[i].x2;
plat[i].index = i;
}
sort(plat + 1, plat + n + 1, cmp);
for (int i = 1; i <= n; ++i)
{
p2[plat[i].index] = i;
}
int l=0, r=0;
for (int i = 1; i <= n; ++i)
{
for (int j = p2[i] + 1; j <= n; ++j)
{
if (plat[p2[i]].x1 > plat[j].x1 && plat[p2[i]].x1 < plat[j].x2)
{
l = plat[j].index;
break;
}
}
for (int j = p2[i] + 1; j <= n; ++j)
{
if (plat[p2[i]].x2 > plat[j].x1 && plat[p2[i]].x2 < plat[j].x2)
{
r = plat[j].index;
break;
}
}
cout << l << ' ' << r << endl;
l = r = 0;
}
}