/*
TASK:music
LANG:C++
*/

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

struct per
{
	string name;
	double point;
	int n,d;
}mas[10000];

int days;
int inc;
per nul;

double hfs(per x,per y)
{
	if(fabs(x.point-y.point)>0.00000001) return x.point-y.point;
	else
	{
		if(x.d>y.d) return -1;
		else
		{
			if(x.d==y.d&&x.n>y.n) return -1;
		}
	}
	return 1;
}

void pyr()
{
	if(inc==0) return;
	int s=inc;
	int par=(inc-1)/2;
	while(1)
	{
		int t=0;
		if(hfs(mas[par],mas[s])<0)
		{
			t=1;
			per x;
			x=mas[par];
			mas[par]=mas[s];
			mas[s]=x;
		}
		if(t==0||par==0) break;
		s=par;
		par=(s-1)/2;
	}
}

void read(int x,int y)
{
	for(int i=0;i<x;i++)
	{
		cin>>mas[inc].name;
		cin>>mas[inc].point;
		mas[inc].n=i;
		mas[inc].d=y;
		pyr();
		inc++;
	}
}

void clr()
{
	mas[0]=mas[inc-1];
	mas[inc-1]=nul;
	inc--;
	if(inc-1==0) return;
	int ind=0;
	while(1)
	{
		int in;
		if(hfs(mas[2*ind+1],mas[2*ind+2])<0)in=2*ind+2;
		else in=2*ind+1;
		if(hfs(mas[ind],mas[in])<0)
		{
			per x;
			x=mas[ind];
			mas[ind]=mas[in];
			mas[in]=x;
		}
		else break;
		ind=in;
		if(mas[2*ind+1].point==0) break;
	}
}

int main()
{
	cin>>days;
	for(int i=0;i<days;i++)
	{
		int nc;
		cin>>nc;
		read(nc,i);
		cin>>nc;
		for(int j=0;j<nc;j++) clr();
	}
	cout<<mas[0].name<<endl;
	return 0;
}
