#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<string, int> m;
  int highest = 0;
  for (int i = 0; i < n; ++i) {
  	string s;
    int a;
    cin >> s >> a;
    m[s] = a;
  }
  for (auto x : m) highest = max(highest, x.second);
  int second_highest = 0;
  for (auto x : m) if (x.second != highest) second_highest = max(second_highest, x.second);
  string ans = "";
  for (auto x : m) if (x.second == second_highest) ans = x.first;
  cout << ans << endl;
  return 0;
}
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	LL N;
	cin >> N;

	vector<LL> ret;
	FOR(i, 1, max(2LL, (LL)sqrt(N)) + 1)
	{
		if((N % i) == 0){
			ret.push_back(i);
			ret.push_back(N / i);
		}
	}

	SORT(ret);
	ret.erase(unique(ALL(ret)), ret.end());

	EACH(r, ret){
		cout << r << endl;
	}

	return 0;
}
