• + 0 comments
    my_list=[] # list of records 
    score_list=[]#list for scores to know target score
    for _ in range(int(input())):
        name=input()
        score=float(input())
        my_list.append([name,score])
        score_list.append(score)
    
    
    min_score=min(score_list) # know minimum score 
    target_score = max(score_list) # put target score maximum value 
    for value in score_list:
        # know the second minimum value (target)
        if value > min_score and value<target_score:
            target_score=value
    
    target_names = [] # to put names has target score 
    for item in my_list:
        if item[1] == target_score:
            target_names.append(item[0])
    
    target_names.sort() # sort name alphabetically 
    for x in target_names:
        print(x)