//#include<stdio.h>
//
//struct jh
//{
// char name[11];
// int sc1;
// int sc2;
// int sc3;
//};
//
//int main()
//
//{
// struct jh tg[100] = {};
// int a, i, j = 0, k, b = 0, c = 0;
//
// scanf("%d", &a);
//
// for(i=0; i<a; i++)
// {
// scanf("%s", tg[i].name);
//
// scanf("%d", &tg[i].sc1);
//
// scanf("%d", &tg[i].sc2);
//
// scanf("%d", &tg[i].sc3);
// }
//
// for(i=0; i<a; i++)
// {
// if(j<tg[i].sc1)
// {
// j = tg[i].sc1;
// k=i;
// }
// }
//
// for(i=0; i<a; i++)
// {
// if(tg[k].sc2<tg[i].sc2)
// {
// b++ ;
// }
//
// if(tg[k].sc3<tg[i].sc3)
// {
// c++ ;
// }
// }
//printf("%s %d %d", tg[k].name, b+1, c+1);
//
//return 0;
//}
//#include <stdio.h>
//
//struct ao
//{
// int cr;
// int nb;
// int score;
//};
//
//
//int main()
//{
// struct ao jb[100];
// int i, j, k, a, b, c;
//
// scanf("%d", &a);
//
// for(i=0; i<a; i++)
// {
// scanf("%d %d %d", &jb[i].cr, &jb[i].nb, &jb[i].score);
// }
//
//
// for()
//
//
//
//}
//
//
struct ap
{
int cn;
int st;
int score;
};
int main()
{
int i, d, n, a, k;
int max,mi;
struct ap s[1000] = {};
scanf("%d", &n);
for(i=1; i<=n; i++)
{
scanf("%d %d %d", &s[i].cn, &s[i].st, &s[i].score);
}
for(i=1; i<=3; i++)
{
max = 0;
for(d=1; d<=n; d++)
{
if(s[d].score > max)
{
max = s[d].score;
mi = d;
}
}
printf("%d %d\n", s[mi].cn, s[mi].st);
s[mi].score = 0;
}
return 0;
}