//#include <stdio.h>
//#include <stdlib.h>
//int n;
//
//void f(int a, int b)// a 가로 . b 세로
//{
// if (b == 1)
// {
// printf("*");
// }
// if (a == b)
// {
// printf("*");
// }
// if (n == 1) return;
// f(n - 1, n - 1);
//}
//int main()
//{
// scanf("%d", &n);
// f(n,n);
// return 0;
//}
//#include <stdio.h>
//
//int n;
//void f(int n)
//{
// if (n == 1)
// {
// printf("%d\n", n);
// return;
// }
//
// if (n % 2 == 1)
// {
// f(3 * n + 1);
// }
// else
// {
// f(n / 2);
// }
// printf("%d\n", n);
//
//
//}
//int main()
//{
// scanf("%d", &n);
// f(n);
// return 0;
//}
//#include <stdio.h>
//
//int SuperSum(int k, int n)
//{
// if (k == 0) return n;
// if (n == 0) return 0;
// 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));
// return 0;
//
//}
/*
#include <stdio.h>
int n;
void star(int a)
{
printf("*");
if(a==1) return;
star(a-1);
}
void f(int n)// a 가로 . b 세로
{
if(n==0) return;
f(n-1);
star(n);printf("\n");
}
int main()
{
scanf("%d", &n);
f(n);
return 0;
}
*//*
#include <stdio.h>
struct student
{
char name[20];
int age, id;
char grade;
};
typedef struct
{
char name[20];
int age, id;
char grade;
}student;
int main()
{
struct student st[100];
student st[100];
scanf("%d",&st[1].age);
scanf("%s",st[1].name);
}
*/
//#include <stdio.h>
//
//typedef struct
//{
// char name[20];
// int a,b,c;
//}student;
//
//int main()
//{
// int n,i;
// scanf("%d", &n);
// student st[101];
// student max;
// int maxA = -1, b_grade=1 , c_grade=1;
//
// for(i=0;i<n;i++)
// {
// scanf("%s", st[i].name);
// scanf("%d %d %d", &st[i].a,&st[i].b,&st[i].c);
// }
// for(i=0;i<n;i++)
// {
// if(maxA < st[i].a) {
// maxA = st[i].a;
// max = st[i];
// }
// //max=st[i].a > st[i-1].a ? st[i] : st[i-1];
// }
// for(i=0;i<n;i++)
// {
// if(max.b < st[i].b)
// {
// b_grade++;
// }
// }
// for(i=0;i<n;i++)
// {
// if(max.c <st[i].c)
// {
// c_grade++;
// }
// }
// printf("%s %d %d", max.name, b_grade, c_grade);
// return 0;
//}
//#include <stdio.h>
//
//typedef struct
//{
// int a,b;
//}student;
//
//int main()
//{
// int n,i,compare=1;
// scanf("%d", &n);
// student st[200];
//
// for(i=0;i<n;i++)
// {
// scanf("%d", &st[i].a);
// }
//
// for(i=0;i<n;i++)
// {
// compare=1;
// printf("%d ", st[i].a);
// for(int j = 0;j<n;j++)
// {
// if(st[i].a<st[j].a)
// {
// compare++;
// }
//
// }
// printf("%d\n", compare);
// }
// return 0;
//}
#include <stdio.h>
typedef struct
{
int a,b,score;
} student;
int main()
{
int n,i,j,k, max,medal[101]={};
scanf("%d", &n);
student st[100];
for(i=0; i<n; i++)
{
scanf("%d", &st[i].a);
scanf("%d", &st[i].b);
scanf("%d", &st[i].score);
}
for(k=0; k<3; k++)
{
for(i=0; i<n; i++)
{
if(medal[i]==2)
{
for(j=0;j<n;j++)
{
if(st[j].a==i)
{
st[j].score=0;
}
}
}
}
max=0;
for(i=0; i<n; i++)
{
if(st[max].score<st[i].score)
{
max=i;
}
}
st[max].score=0;
medal[st[max].a]++;
printf("%d %d\n",st[max].a,st[max].b);
}
return 0;
}