#include <iostream> using namespace std; int main() { int N; cin>>N; int H[1001],L[1001],R[1001]; for(int i=1;i<=N;i++){ cin>>H[i]>>L[i]>>R[i]; } for(int i=1;i<=N;i++){ int AnsL=0,AnsR=0,h1=0,h2=0; for(int j=1;j<=N;j++){ if(H[j]<H[i]){// if(H[j]>h1&&L[j]<L[i]){ h1=H[j]; AnsL=j; } if(H[j]>h2&&R[j]>R[i]){ h2=H[j]; AnsR=j; } } } cout<<AnsL<<" "<<AnsR<<endl; } return 0; }