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

struct human
{
       string name;
       double points;
};

struct Node
{
       human data;
       Node* pNext;
};

Node *pRoot=NULL;
int N,K,Date;
void Read();
void Process();

int main()
{
    cin>>N;
    
    for(Date=0;Date<N;Date++)
    {
            Read();
            for(int i=0;i<K;i++)
                    Process();
    }
    
    cout<<pRoot->data.name<<endl;

    return 0;
}

void Read()
{
     int M;
     cin>>M;
     
     for(int i=0;i<M;i++)
     {
             Node* h=new Node;
             cin>>h->data.name>>h->data.points;
             h->pNext=NULL;
             
             if(pRoot==NULL)
             {
                 pRoot=h;
                 pRoot->pNext=NULL;
             }
             else
             {
                 Node* temp=pRoot;
                 while(h->pNext==0)
                 {
                     if(h->data.points > temp->data.points)
                         if(temp==pRoot)
                         {
                             h->pNext=pRoot;
                             pRoot=h;
                         }
                         else
                         {
                             Node* prev=pRoot;
                             while(prev->pNext!=temp) prev=prev->pNext;
                             prev->pNext=h;
                             h->pNext=temp;
                         }
                     
                     else if(temp->pNext==NULL)
                     {
                         temp->pNext=h;
                         h->pNext=NULL;
                         break;
                     }
                     
                     temp=temp->pNext;
                 }
             }
     }
     
     cin>>K;
}

void Process()
{
     Node* d=pRoot;
     pRoot=pRoot->pNext;
     delete d;
}
