• + 0 comments

    if name == 'main':

    #build the nested list
    students = []
    for _ in range(int(input())):
        name = input()
        score = float(input())                
        students.append([score, name])
    #print("students ",students)
    
    #sort sutdents list ascending
    ordered = sorted(students, key=lambda item: (item[0], item[1]))
    #print("ordered ",ordered)
    
    #get the lowest score of ordered student list
    min_score = min(ordered[0] for ordered in ordered)
    #print("first min ",min_score)
    
    #remove the lowest score from the ordered list
    without_min_score = [ordered for ordered in ordered if ordered[0] > min_score ]
    #print("without min ",without_min_score)
    
    #get the second lowest score by getting the min of without_min_score list
    second_min_score = min(without_min_score[0] for without_min_score in without_min_score)
    #print("second min ", second_min_score)
    
    #remove the score above the second lowesrt score
    with_sec_min_score = [without_min_score for without_min_score in without_min_score if without_min_score[0] <= second_min_score ]
    #print("with secon min ",with_sec_min_score)
    
    #map to extract the values
    final2 = list(map(lambda item: item[1] ,with_sec_min_score))
    for i in range(len(final2)):
        print(final2[i])