#include <bits/stdc++.h> #include<math.h> using namespace std; const int MAX_LEN = 100005; struct Student{ int number; int grade; }temp[MAX_LEN]; int main(){ int n; cin>>n; for(int i=0;i<n;++i){ int fir = 0; int sec = 0; cin>>fir; cin>>sec; temp[fir].grade += sec; } int num = 0; int result = 0; for(int i=0;i<MAX_LEN;++i){ if(temp[i].grade > result){ num = i; result = temp[i].grade; } } cout<<num<<" "<<result<<endl; system("pause"); return 0; }