#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); char maxn[5],minn[5],m[5]; int max1=-1,min1=100010,x,y; while(n--) { cin>>m>>x>>y; if(sqrt(x*x+y*y)>max1){ max1=sqrt(x*x+y*y); strcpy(maxn,m); } if(sqrt(x*x+y*y)<min1){ min1=sqrt(x*x+y*y); strcpy(minn,m); } } cout<<minn<<" "<<maxn<<endl; return 0; }