/*
TASK:music
LANG:C++
*/
# include <stdio.h>
# include <string.h>
# define MAXNAME (1<<4)
# define MAXQ (1<<17)
int n,k,step;
struct list {
     char name[MAXNAME];
     double bal;
} queue[MAXQ];
int start,end;

void add() {
     int p = end;
     while(1) {
         if(p-1 < start) break;     
         if(queue[p].bal > queue[p-1].bal) {
              char swapname[MAXNAME];
              double swapbal;
              strcpy(swapname,queue[p].name);
              swapbal = queue[p].bal;

              strcpy(queue[p].name,queue[p-1].name);
              queue[p].bal = queue[p-1].bal;
              strcpy(queue[p-1].name,swapname);
              queue[p-1].bal = swapbal;                
              p--;         
         } else {
             break;       
         }          
     }    
}

void read() {
    char crntname[MAXNAME];
    int crntbal;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &k);
        for(int j = 0; j < k; j++) {
            scanf("%s %lf", queue[end].name,&queue[end].bal);
            add();
            end++;           
        }
        scanf("%d", &step);
        start+=step;                
    }
    printf("%s\n", queue[start].name);
    //for(int i = 0; i < end; i++) {
      //   printf("%s %d\n", queue[i].name,queue[i].bal);        
    //}     
}

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