n=int(eval(input()))

for v in sorted(list(list(input().split())+[i+1] for i in range(n)),key=lambda x:(x[0],-int(x[1]))):print((v[2]))
for v in sorted([[*input().split()]+[i+1] for i in range(int(eval(input())))],key=lambda x:(x[0],-int(x[1]))):print((v[2]))
n = int(eval(input()))
for v in sorted(
    list(list(input().split()) + [i + 1] for i in range(n)),
    key=lambda x: (x[0], -int(x[1])),
):
    print((v[2]))

for v in sorted(
    [[*input().split()] + [i + 1] for i in range(int(eval(input())))],
    key=lambda x: (x[0], -int(x[1])),
):
    print((v[2]))

-n = int(eval(input())) -    list(list(input().split()) + [i + 1] for i in range(n)), +    [[*input().split()] + [i + 1] for i in range(int(eval(input())))],