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


typedef struct
{
        string name;
        pair<double,int> p;
}treple;

typedef struct
{
        bool operator() ( treple a, treple b )
        {
             if(a.p.first>b.p.first) return true;
             
             if(a.p.first<b.p.first) return false;
             
             if(a.p.second<b.p.second) return true;
             
             return false;
        }
}cmp;



set< treple, cmp > s;
set< treple, cmp >::iterator it;
int N,M,K;
int i,j;
treple t;



inline void Read()
{
     cin>>N;
     
     for(i=0;i<N;i++)
     {
         cin>>M;
         
         for(j=1;j<=M;j++)
         {
            cin>>t.name>>t.p.first;
            t.p.second=j;
            
            s.insert(t);
         }
         
         cin>>K;
         
         for(j=0;j<K;j++) s.erase( s.begin() );
     }
     
     t=*s.begin();
     
     cout<<t.name<<"\n";
}

int main()
{
    Read();
    
    return 0;
}

