/*
#include<stdio.h>
int SuperSum(int k,int n)
{
if (k==0)
{
return n;
}
if (n==1)
{
return 1;
}
return SuperSum(k,n-1)+SuperSum(k-1,n);
}
int main()
{
int k,n;
while( scanf("%d %d", &k, &n) != EOF )
printf("%d\n", SuperSum(k, n));
}
*/
/*
#include <stdio.h>
int main()
{
int n,m;
char M,W;
scanf ("%d-%d",&n,&m);
if (m==1||m==3)
{
printf ("19%d",n);
}
else if (m==2||m==4)
{
printf ("20%d",n);
}
if (m==1||m==3)
{
printf ("M");
}
else if (m==2||m==4)
{
printf ("W");
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int n,m;
char M,W;
scanf ("%d-%d",&n,&m);
if (2000)
{
printf ("19%d",n);
}
else if (2000)
{
printf ("20%d",n);
}
if (m==1||m==3)
{
printf ("M");
}
else if (m==2||m==4)
{
printf ("W");
}
return 0;
}
*/
/*
#include <stdio.h>
int main ()
{
int n,n1,n2,n3,m;
char M,F;
scanf ("%d-%d",&n,&m);
n3=n%100;
n2=n%10000/100;
n1=n/10000;
m=m/1000000;
if (m==1||m==2)
{
printf ("19");
}
else
{
printf ("20");
}
printf ("%02d/%02d/%02d ",n1,n2,n3);
if (m==1||m==3)
{
printf ("M");
}
else if (m==2||m==4)
{
printf ("F");
}
return 0;
}
*/
/*
#include <stdio.h>
int gcd(int p, int q)
{
if(p==0)
return q;
return gcd(q%p, p);
}
long long int lcm(int a,int b)
{
return (long long int)a*b/gcd(a, b);
}
int main()
{
int a, b;
scanf("%d%d", &a, &b);
printf("%lld\n", lcm(a, b));
}
*/
/*
#include <stdio.h>
int n;
long long int d[110];
long long int f()
{
long long int min=d[1];
for (int i=1; i<=n; i++)
{
if(min>d[i])
{
min=d[i];
}
}
return min;
}
int main()
{
scanf("%d", &n);
for(int i=1; i<=n; i++)
scanf("%lld", &d[i]);
printf("%lld", f());
return 0;
}
*/
/*
#incude <stdio.h>
struct p
{
int age;
char name[10];
float grade;
};
int main()
{
struct p tom;
struct p st[10];
tom.age=10;
scanf("%d",&tom.age);
for(int i=0;i<10;i++)
{
st[i].age=100;
}
return 0;
}
*/
/*
#include <stdio.h>
struct p
{
int a,b;
};
int main ()
{
struct p st[200];
int n, i,j,cnt=1;
scanf ("%d",&n);
for (i=0;i<n;i++)
{
scanf ("%d",&st[i].a);
}
for (i=0;i<n;i++)
{
cnt=1;
for (j=0;j<n;j++)
{
if(st[i].a<st[j].a)
{
cnt++;
}
}
st[i].b=cnt;
}
for (i=0;i<n;i++)
{
printf ("%d %d\n",st[i].a,st[i].b);
}
return 0;
}
*/
#include <stdio.h>
struct p
{
int a,b,c,d;
char name[11];
};
int main ()
{
struct p st[100];
int n,i,j;
scanf ("%d",&n);
for (i=0;i<n;i++)
{
scanf ("%s %d %d %d",st[i].name,&st[i].a,&st[i].b,&st[i].c);
}
return 0;
}
*/
#include <stdio.h>
struct p
{
int country;
int number;
int score;
};
int main()
{
int i,j,n,a,b,c;
scanf("%d",&n);
struct p st[n];
for(i=0;i<n;i++)
{
scanf("%d %d %d",&st[i].country,&st[i].number,&st[i].score);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(st[i].score > st[j].score)
{
a = st[i].score;
st[i].score = st[j].score;
st[j].score = a;
b = st[i].number;
st[i].number = st[j].number;
st[j].number = b;
c = st[i].country;
st[i].country = st[j].country;
st[j].country = c;
}
}
}
printf("%d %d\n",st[0].country, st[0].number);
printf("%d %d\n",st[1].country, st[1].number);
if(st[0].country == st[1].country)
{
printf("%d %d",st[3].country, st[3].number);
}
else
printf("%d %d",st[2].country, st[2].number);
return 0;
}