/*
TASK:music
LANG: C++
*/
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

#define _MAX 100000
#define _MAX_N 200

class Person
{
public:
	string name;
	double ball;
	bool operator<(Person const & person) const
	{
		if (ball <= person.ball) return false;
		return true;
	}
};

int n;
int m;
int k;
int mTop;
int kTop;
int pTop;
int result;
int mStack[_MAX_N];
int kStack[_MAX_N];
Person pStack[_MAX];

void init()
{
	int temp;
	cin >> n; k = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> mStack[mTop++];
		for (int j = 0; j < mStack[mTop - 1]; j++)
		{
			cin >> pStack[pTop].name;
			cin >> pStack[pTop].ball;
			pTop++;
		}
		cin >> kStack[kTop++];
	}
}

void solve()
{
	int s = 0; int e = mStack[0];
	for (int i = 0; i < mTop; i++)
	{
		sort(pStack + s, pStack + e);
		s = kStack[i];
		e += mStack[i];
		result += s;
	}
	cout << pStack[result].name << endl;
}

int main()
{
	init();
	solve();
	
	return 0;
}
