#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int M=1005;
inline int read(){
	char c=getchar();int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=0;
	for(;c<='9'&&c>='0';c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?x:-x;
}
struct node{
	char s[20];int x;
	bool operator <(const node &t)const{
		return x>t.x;
	}
}a[M];
int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		scanf("%s",a[i].s);a[i].x=read();
	}
	sort(a+1,a+1+n);
	printf("%s",a[2].s);
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
    cout<<(2*i)%n+1<<' '<<(2*i+1)%n+1<<'\n';
  return 0;
}