/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
struct schedule
{
char name[99];
int day;
};
swap(struct schedule *pa,struct schedule *pb)
{
struct schedule room;
room = *pb;
*pb = *pa;
*pa = room;
}
int main()
{
int n,a,b,c,i,j,ret;
struct schedule s[100];
scanf("%d",&n);
for(i = 0; i < n; i++)
{
scanf("%s %d %d %d",s[i].name,&a,&b,&c);
s[i].day = a*10000 + b*100 + c;
}
for(i = 0; i < n-1; i++)
{
for(j = 0; j < n-i; j++)
{
if(s[j].day < s[j+1].day)
{
swap(&s[j],&s[j+1]);
}
}
}
for(i = 0 ; i< n ; i++)
{
for(j= 0 ; j < n-i; j++)
{
if(s[j].day == s[j+1].day)
{
if(strcmp(s[j].name,s[j+1].name)==-1)
{
swap(&s[j],&s[j+1]);
}
}
}
}
for(i = n-1; i >=0 ; i--)
{
printf("%s\n",s[i].name);
}
return 0;
}
*/
#include <stdio.h>
struct competition
{
int country;
int num;
int score;
};
int main()
{
int n, k, max= 0, max2 = 0, mm2= 0, i, j, mm = 0;
int cnt = 0,cc[3]={};
struct competition c[100];
scanf("%d",&n);
for(k = 0; k < n; k++)
{
scanf("%d %d %d",&c[k].country,&c[k].num,&c[k].score);
}
for(i = 0 ; i < 3 ; i++)
{
if(i == 2 && cc[0]==cc[1])
{
for(j = 0; j<n ; j++)
{
if(c[j].country==cc[0])
{
c[j].score = 0;
}
}
}
max = 0;
mm = 0;
for(j = 0; j < n; j++)
{
if(max < c[j].score)
{
max = c[j].score;
mm = j;
}
}
c[mm].score = 0;
cc[i]=c[mm].country;
printf("%d %d\n",c[mm].country,c[mm].num);
}
//i==2일 때,
//1등 한 나라 == 2등 한 나라, 그 나라의 애들의 점수를 다 0점 처리
// 그리고 나서 3등 구하기
//각 나라별 획득 메달 수를 저장하는 배열
//금메달 딴 나라, 은메달 딴 나라 ++
// 나라별 획득 메달 수가 2개가 된 나라가 있으면
//그 나라의 점수들을 0점으로 처리
return 0;
}