n = int(input())
tbl = []
s = []
p = []
for i in range(n):
    l = list(map(str,input().split()))
    l[1] = int(l[1])
    l2 = [l[1], l[0], i + 1]
    tbl.append(l2)
    s.append(l2[1])
    p.append(l2[0])

p.sort()
p.reverse()
tbl2 = []
for i in range(n):
    for j in range(n):
        if(tbl[j][0] == p[i]):
            tbl2.append(tbl[j])
s = list(set(s))
s.sort()
for i in range(len(s)):
    for j in range(len(tbl2)):
        if (tbl2[j][1] == s[i]):
            print(tbl2[j][2]) n = int(input()) n int(input()) int input() input tbl = [] tbl [] s = [] s [] p = [] p [] for i in range(n):
    l = list(map(str,input().split()))
    l[1] = int(l[1])
    l2 = [l[1], l[0], i + 1]
    tbl.append(l2)
    s.append(l2[1])
    p.append(l2[0]) i range(n) range n l = list(map(str,input().split())) l list(map(str,input().split())) list map(str,input().split()) map str input().split() ().split () input split l[1] = int(l[1]) l[1] l 1 int(l[1]) int l[1] l 1 l2 = [l[1], l[0], i + 1] l2 [l[1], l[0], i + 1] l[1] l 1 l[0] l 0 i + 1 i 1 tbl.append(l2) tbl.append tbl append l2 s.append(l2[1]) s.append s append l2[1] l2 1 p.append(l2[0]) p.append p append l2[0] l2 0 p.sort() p.sort p sort p.reverse() p.reverse p reverse tbl2 = [] tbl2 [] for i in range(n):
    for j in range(n):
        if(tbl[j][0] == p[i]):
            tbl2.append(tbl[j]) i range(n) range n for j in range(n):
        if(tbl[j][0] == p[i]):
            tbl2.append(tbl[j]) j range(n) range n if(tbl[j][0] == p[i]):
            tbl2.append(tbl[j]) tbl[j][0] == p[i] tbl[j][0] [j] tbl j 0 p[i] p i tbl2.append(tbl[j]) tbl2.append tbl2 append tbl[j] tbl j s = list(set(s)) s list(set(s)) list set(s) set s s.sort() s.sort s sort for i in range(len(s)):
    for j in range(len(tbl2)):
        if (tbl2[j][1] == s[i]):
            print(tbl2[j][2]) i range(len(s)) range len(s) len s for j in range(len(tbl2)):
        if (tbl2[j][1] == s[i]):
            print(tbl2[j][2]) j range(len(tbl2)) range len(tbl2) len tbl2 if (tbl2[j][1] == s[i]):
            print(tbl2[j][2]) tbl2[j][1] == s[i] tbl2[j][1] [j] tbl2 j 1 s[i] s i print(tbl2[j][2]) print tbl2[j][2] [j] tbl2 j 2 n = int(input()) int(input()) n s = list(set(s)) list(set(s)) s s = [] [] s p = [] [] p l = list(map(str,input().split())) list(map(str,input().split())) l l2 = [l[1], l[0], i + 1] [l[1], l[0], i + 1] l2 tbl = [] [] tbl tbl2 = [] [] tbl2
n = int(input())
tbl = []
s = []
p = []
for i in range(n):
    l = list(map(str,input().split()))
    l[1] = int(l[1])
    l2 = [l[1], l[0], i + 1]
    tbl.append(l2)
    s.append(l2[1])
    p.append(l2[0])

p.sort()
p.reverse()
tbl2 = []
for i in range(n):
    for j in range(n):
        if(tbl[j][0] == p[i]):
            tbl2.append(tbl[j])
s = list(set(s))
s.sort()
for i in range(len(s)):
    for j in range(len(tbl2)):
        if (tbl2[j][1] == s[i]):
            print(tbl2[j][2])
