N=int(eval(input()))

data=[input().split() for i in range(N)]

data_name=[]

for i in range(N):

    if data[i][0] in data_name:

        continue

    else:

        data_name.append(data[i][0])

data_name_sort=sorted(data_name)

#print(data_name_sort)

data_point=[]

for i in range(N):

    num=0

    for j in range(len(data_name_sort)):

        if data[i][0]==data_name_sort[j]:

            num+=(len(data_name)-j)*200+int(data[i][1])

        else:

            continue

    data_point.append(num)

#print(data_point)

data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]

#print(data_sort)

for i in range(N):

    ans=int(data_sort[i])+1

    print(ans)
N=int(eval(input()))

d=[input().split() for i in range(N)]

name=[]

for i in range(N):

    d[i].append(i+1)

    d[i][1]=int(d[i][1])

    name.append(d[i][0])

Name=list(set(name))

Name.sort()

d.sort()

for i in range(len(Name)):

    li=[]

    for j in range(N):

        if Name[i]==d[j][0]:

            li.append([d[j][1],d[j][2]])

        else:

            continue

    li.sort()

    Li=li[::-1]

    for k in range(len(li)):

        print((Li[k][1]))
N = int(eval(input()))
data = [input().split() for i in range(N)]
data_name = []
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort = sorted(data_name)
# print(data_name_sort)
data_point = []
for i in range(N):
    num = 0
    for j in range(len(data_name_sort)):
        if data[i][0] == data_name_sort[j]:
            num += (len(data_name) - j) * 200 + int(data[i][1])
        else:
            continue
    data_point.append(num)
# print(data_point)
data_sort = [i for i, _ in sorted(enumerate(data_point), key=lambda x: x[1])][::-1]
# print(data_sort)
for i in range(N):
    ans = int(data_sort[i]) + 1
    print(ans)

N = int(eval(input()))
d = [input().split() for i in range(N)]
name = []
for i in range(N):
    d[i].append(i + 1)
    d[i][1] = int(d[i][1])
    name.append(d[i][0])
Name = list(set(name))
Name.sort()
d.sort()
for i in range(len(Name)):
    li = []
    for j in range(N):
        if Name[i] == d[j][0]:
            li.append([d[j][1], d[j][2]])
        else:
            continue
    li.sort()
    Li = li[::-1]
    for k in range(len(li)):
        print((Li[k][1]))

-data = [input().split() for i in range(N)] -data_name = [] +d = [input().split() for i in range(N)] +name = [] -    if data[i][0] in data_name: -        continue -    else: -        data_name.append(data[i][0]) -data_name_sort = sorted(data_name) -# print(data_name_sort) -data_point = [] -for i in range(N): -    num = 0 -    for j in range(len(data_name_sort)): -        if data[i][0] == data_name_sort[j]: -            num += (len(data_name) - j) * 200 + int(data[i][1]) +    d[i].append(i + 1) +    d[i][1] = int(d[i][1]) +    name.append(d[i][0]) +Name = list(set(name)) +Name.sort() +d.sort() +for i in range(len(Name)): +    li = [] +    for j in range(N): +        if Name[i] == d[j][0]: +            li.append([d[j][1], d[j][2]]) -    data_point.append(num) -# print(data_point) -data_sort = [i for i, _ in sorted(enumerate(data_point), key=lambda x: x[1])][::-1] -# print(data_sort) -for i in range(N): -    ans = int(data_sort[i]) + 1 -    print(ans) +    li.sort() +    Li = li[::-1] +    for k in range(len(li)): +        print((Li[k][1]))