#include <bits/stdc++.h>

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int n;
	int number;
	int getNum;
	int numOfGetFish[21];
	int winnerIndex;
	int maxFish = 0;

	scanf("%d", &n);
	while( scanf("%d%d", &number, &getNum) != EOF )
	{
		numOfGetFish[number - 1] += getNum;
	}
	loop(i, 0, n)
	{
		if( numOfGetFish[i] > maxFish )
		{
			winnerIndex = i + 1;
			maxFish = numOfGetFish[i];
		}
	}
	printf("%d %d\n", winnerIndex, maxFish);
	return (0);
}