/*
TASK: music
LANG: C++
*/
#include <iostream>
#include <queue>
//#include <string>
using namespace std;

class man
{
      public:
       double mark;
       char name[11];
       short arr;
       bool operator<(const man& A) const
       {
            if ((*this).mark == A.mark)
             return (*this).arr > A.arr;
            return (*this).mark < A.mark;
       }
};
priority_queue <man> x;
int N;

int main()
{
    int i, j, m, c;
    man y;
    cin >> N;
    for (i=0;i < N;i++)
    {
        cin >> m; // coming candidates
        for (j=0;j < m;j++)
        {
            cin >> y.name >> y.mark;
            y.arr = j;
            x.push(y);
        }
        
        /*int len = x.size();
        for (j=0;j < len;j++)
        {
            cout << x.top().name << " ";
            x.pop();
        }cout << endl;*/
        
        cin >> m; // number of candidates
        for (j=0;j < m;j++)
         if (!x.empty())
          x.pop();
    }
    
    cout << (x.top()).name << endl;      
    
    //system("pause");
    return 0;
}
