//#include<stdio.h>
//
//long long int sum=0;
//long long int SuperSum(long long int k,long long int n)
//{
// if(k==0)
// {
// return n;
// }
// else
// {
// sum += n;
// if(n==0)
// {
// return SuperSum(k-1,n);
// }
// else
// {
//
// return SuperSum(k,n-1);
// }
// }
//}
//int main(void)
//{
// long long int k,n;
// while( scanf("%lld %lld", &k, &n) != EOF )
// {
// printf("%lld\n", SuperSum(k, n));
// sum = 0;
// }
//}
//
//#include<stdio.h>
//
//int n;
//int res(n)
//{
// int sum,arr[201]={0};
// arr[0]=1;
// arr[1]=1;
// return arr[n]=arr[n-1]+arr[n-2];
//}
//
//int main()
//{
// scanf("%d",&n);
// printf("%d",res(n));
//}
//
//#include<stdio.h>
//
//struct human {
// char name[15];
// double height;
// double weight;
// char school[50];
// int age;
// char phoneNumber[20];
//};
//
//int main() {
// struct human leejunseo;
// struct human people[500];
// struct human p;
//
// people[0].age = 50;
// people[0].height = 177;
// people[1].age = 40;
// people[1].height = 190;
//
// p = people[0];
// people[0] = people[1];
// people[1] = p;
//
// printf("%d %d", people[0].age, people[1].age);
//
//}
//
//#include<stdio.h>
//
//
//struct student {
// char name[100];
// int one;
// int two;
// int three;
//};
//
//int main()
//{
// int f,i,j;
// int twoCnt=0,threeCnt=0;
// int max=-1;
// int mm;
// int arr[101];
// struct student s[101] = {0};
// scanf("%d",&f);
// for(i=0;i<f;i++)
// {
// scanf("%s %d %d %d",s[i].name, &s[i].one, &s[i].two, &s[i].three);
// }
// for(j=0;j<f;j++)
// {
// if(max<s[j].one)
// {
// max=s[j].one;
// mm = j;
// }
// }
// for(j=0; j<f; j++)
// {
// if(s[mm].two < s[j].two)
// {
// twoCnt++;
// }
// }
// for(j=0;j<f;j++)
// {
// if(s[mm].three < s[j].three)
// {
// threeCnt++;
// }
// }
// printf("%s %d %d",s[mm].name,twoCnt+1,threeCnt+1);
//}
//
//#include<stdio.h>
//
//struct ranking
//{
// int rank;
// int grade;
//};
//
//int main()
//{
// int n,i,j;
// int cnt=0;
// struct ranking r[201];
//
// scanf("%d",&n);
// for(i=0; i<n; i++)
// {
// scanf("%d",&r[i].grade);
// }
//
// for(i=0; i<n; i++)
// {
// cnt=0;
// for(j=0; j<n; j++)
// {
// if(r[j].grade>r[i].grade)
// {
// cnt++;
// }
// }
// r[i].rank=cnt+1;
// }
// for(i=0;i<n;i++)
// {
// printf("%d %d\n",r[i].grade,r[i].rank);
// }
//}
#include<stdio.h>
struct contest
{
int world;
int number;
int score;
};
int main()
{
int n;
int i,j;
int cnt=0;
int max=-1,mm;
struct contest a[101];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&a[i].world,&a[i].number,&a[i].score);
}
for(j=0;j<n;j++)
{
if(max<a[j].score)
{
max=a[j].score;
mm=j;
}
}
a[mm].rank=j+1;
a[mm].score=0;
for(i=0;i<n;i++)
{
printf("%d %d\n",a[i].world,a[i].number);
}
}



