n = int(eval(input()))

l = [list(input().split()) for i in range(n)]

s,p = [list(i) for i in zip(*l)]

p = [int(i) for i in p]

z = list(set(s))

z.sort()

m = list(p)

m.sort(reverse = True)

l = []

 

k = 0

for i in range(len(z)):

    l.append(k)

    k += 200

 

o = []

for i in range(n):

    w = l[z.index(s[i])]

    w += m.index(p[i])

    o.append(w)

 

r = list(o)

r.sort()

for i in range(n):

    print((o.index(r[i]) + 1)) 
n = int(eval(input()))

l = []

for i in range(1,n+1):

    s,p = input().split()

    t = [s,int(p),i]

    l.append(t)

l.sort()

def check(m,i):

    z = list(l[m:i])

    z.sort(key = lambda x: x[1] , reverse = True)

    for j in range(i-m):

        print((z[j][2]))

m = 0

for i in range(1,n):

    if l[m][0] != l[i][0]:

        check(m,i)

        m = i

check(m,n)
n = int(eval(input()))
l = [list(input().split()) for i in range(n)]
s, p = [list(i) for i in zip(*l)]
p = [int(i) for i in p]
z = list(set(s))
z.sort()
m = list(p)
m.sort(reverse=True)
l = []
k = 0
for i in range(len(z)):
    l.append(k)
    k += 200
o = []
for i in range(n):
    w = l[z.index(s[i])]
    w += m.index(p[i])
    o.append(w)
r = list(o)
r.sort()
for i in range(n):
    print((o.index(r[i]) + 1))

n = int(eval(input()))
l = []
for i in range(1, n + 1):
    s, p = input().split()
    t = [s, int(p), i]
    l.append(t)
l.sort()


def check(m, i):
    z = list(l[m:i])
    z.sort(key=lambda x: x[1], reverse=True)
    for j in range(i - m):
        print((z[j][2]))


m = 0
for i in range(1, n):
    if l[m][0] != l[i][0]:
        check(m, i)
        m = i
check(m, n)

-l = [list(input().split()) for i in range(n)] -s, p = [list(i) for i in zip(*l)] -p = [int(i) for i in p] -z = list(set(s)) -z.sort() -m = list(p) -m.sort(reverse=True) -k = 0 -for i in range(len(z)): -    l.append(k) -    k += 200 -o = [] -for i in range(n): -    w = l[z.index(s[i])] -    w += m.index(p[i]) -    o.append(w) -r = list(o) -r.sort() -for i in range(n): -    print((o.index(r[i]) + 1)) +for i in range(1, n + 1): +    s, p = input().split() +    t = [s, int(p), i] +    l.append(t) +l.sort() + + +def check(m, i): +    z = list(l[m:i]) +    z.sort(key=lambda x: x[1], reverse=True) +    for j in range(i - m): +        print((z[j][2])) + + +m = 0 +for i in range(1, n): +    if l[m][0] != l[i][0]: +        check(m, i) +        m = i +check(m, n)