/*
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char name[10];
int num;
double grade;
}student;
int main()
{
//student s;
//s.grade=4.5;
//scanf("%lf",&s.grade);
student arr[50];
for()
{
scanf("%d",&arr[i].num);
}
return 0;
}
*/
#include <stdio.h>
typedef struct
{
int c;
int a;
}student;
int main()
{
int n, x,m[4],r[4],t[4],j,i,b[101];
student s[101];
scanf("%d",&n);
for (i=1;i<=n;i++)
{
scanf("%d %d %d", &s[i].c,&s[i].a, &b[i]);
}
for(j=1;j<=3;j++)
{
x=0;
for (i=1;i<=n;i++)
{
if (b[i]>x&&b[i]!=m[1]&&b[i]!=m[2])
{
x=b[i];
r[j]=s[i].c;
t[j]=s[i].a;
}
}
m[j]=x;
}
if(r[1]==r[2]&&r[2]==r[3])
{
x=0;
for (i=1;i<=n;i++)
{
if (b[i]>x&&b[i]!=m[1]&&b[i]!=m[2]&&b[i]!=m[3]&&s[i].c!=r[1])
{
r[3]=s[i].c;
t[3]=s[i].a;
}
}
}
for (i=1;i<=3;i++)
{
printf("%d %d\n", r[i], t[i]);
}
return;
}
fkfkfkfkdjfkjfr세iorejierufijmfierjf+++++++++ ㅅ