#include <iostream> #include <algorithm> #include <string> using namespace std; struct Node{ string name; string time; }; bool Bigger(Node&a,Node&b){ return a.time>b.time; } bool Smaller(Node&a,Node&b){ return a.time<b.time; } int main() { int n; string a,b,c; while(cin>>n){ Node*bigger=new Node[n]; Node*smaller=new Node[n]; for(int i=0;i<n;++i){ cin>>a>>b>>c; bigger[i].name=a; bigger[i].time=c; smaller[i].name=a; smaller[i].time=b; } sort(bigger,bigger+n,Bigger); sort(smaller,smaller+n,Smaller); cout<<smaller[0].name<<" "<<bigger[0].name<<endl; } } // 64 位输出请用 printf("%lld")