/*
TASK: music
LANG: C++
*/
#include <iostream>
#include <queue>
using namespace std;
class competitor
{
      double bal;
      int index;
      string name;
      
      public:
      competitor(string s, double b, int i)
      {
           name = s;
           bal = b;
           index = i;
      }
      
      double get_bal() {return bal;}
      
      int get_index() {return index;}
      
      bool operator<(competitor A) const
      {
           if (bal != A.get_bal())
            return bal < A.get_bal();
           return index > A.get_index();
      }
      
      string get_name()
      {
             return name;
      }
};

int main()
{
    long long n;
    priority_queue<competitor> q;
    cin >> n;
    int index = 0;
       
    for (int i = 0; i < n; i++)
    {
        int m;
        cin >> m;
        for (int j = 0; j < m; j++)
        {
            string name;
            double bal;
            cin >> name >> bal;
            competitor forpush(name, bal, index++);
            q.push(forpush);
        }
        
        int forday;
        cin >> forday;
        for (int j = 0; j < forday && !q.empty(); j++)
         q.pop();
    }
    
    
    competitor res = q.top();
    cout << res.get_name() << endl;
    return 0;
}
         
        
