#include <iostream>
#include <math.h>
using namespace std;
int main() {
int N;
string ansMax,ansMin,id;
double x,y,Max,Min;
cin>>N;
for(int i = 0;i<N;i++)
{
cin>>id>>x>>y;
double t = x*x + y*y;
if(i == 0)
{
Max = t;
Min = t;
ansMax = id;
ansMin = id;
}
else
{
if(t>Max)
{
Max = t;
ansMax = id;
}
if(t<Min)
{
Min = t;
ansMin = id;
}
}
}
cout<<ansMin<<" "<<ansMax<<endl;
return 0;
}