/*
TASK:music
LANG:C++
*/

#include<iostream>
#include<algorithm>

using namespace std;

struct kast {
       char name[12];
       double bal;
};

int N,day,beg,end=0;

kast hotel[10024];
int ind[10024],br;

bool cmp(int a,int b) {
    return hotel[a].bal<=hotel[b].bal;
}

int main() {
    cin >> N;
    for(int i=0;i<N;i++) {
            cin>>day;
            for(int j=0;j<day;j++) {cin>>hotel[end].name>>hotel[end].bal;
                                      ind[br++]=end;end++;}
            
            cin>>day;
            if (day>0) sort(ind,ind+br,cmp);
            for(int j=0;j<day;j++) br--;
    }
    cout<<hotel[ind[br-1]].name;
    return 0;
}
