N=int(eval(input()))

que=[]

for i in range(N):

    s,p=list(input().split())

    que.append((s,int(p),i+1))

que.sort(key=lambda x:(x[0],-x[1]))

for x in que:

    print((x[-1]))
N,que=int(eval(input())),[]

for i in range(N):

    s,p=list(input().split())

    que.append((s,-int(p),i+1))

que.sort()

for x in que:

    print((x[-1]))
N = int(eval(input()))
que = []
for i in range(N):
    s, p = list(input().split())
    que.append((s, int(p), i + 1))
que.sort(key=lambda x: (x[0], -x[1]))
for x in que:
    print((x[-1]))

N, que = int(eval(input())), []
for i in range(N):
    s, p = list(input().split())
    que.append((s, -int(p), i + 1))
que.sort()
for x in que:
    print((x[-1]))

-N = int(eval(input())) -que = [] +N, que = int(eval(input())), [] -    que.append((s, int(p), i + 1)) -que.sort(key=lambda x: (x[0], -x[1])) +    que.append((s, -int(p), i + 1)) +que.sort()