/*
TASK:music
LANG:C++
*/
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
struct idol
{
       string name;
       float bal;
       int day;
       int h;
       bool operator < (idol B)
       const
       {
           if(bal==B.bal)
           {
                     if(day==B.day)
                                     return h>B.h;
                     else return day>B.day;
           }
           else return bal<B.bal;
       }
};
priority_queue<idol> d;
int n,m,k;

int main()
{
 //   freopen("in.tmp","r",stdin);
  //  freopen("out.tmp","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
            cin>>m;
            for(int j=1;j<=m;j++)
            {
                    idol tmp;
                    cin>>tmp.name>>tmp.bal;
                    tmp.day=i;
                    tmp.h=j;
                    d.push(tmp);
            }
            cin>>k;
            for(int g=1;g<=k && !d.empty();g++) d.pop(); 
    }

    cout<<d.top().name<<endl;
  
}
