/*
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 kStack[_MAX_N];
Person mStack[_MAX];

void init()
{
	int temp;
	cin >> n; k = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> m;
		for (int j = 0; j < m; j++)
		{
			cin >> mStack[mTop].name;
			cin >> mStack[mTop].ball;
			mTop++;
		}
		cin >> temp;
		k += temp;
	}
}

void solve()
{
	sort(mStack, mStack + mTop);
	cout << mStack[k].name << endl;
}

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