N = int(input())
S_list = []
P_list = []
c = []

for i in range(N):
    S, P = input().split()
    S_list.append(S)
    P_list.append(int(P))

m = S_list
m = list(set(m))
m = sorted(m)

n = 0
a = []
b = []
for i in m:
    for j in range(N):
        if i == S_list[j]:
            a.append(j)
    n = len(a)
    if n != 1:
        for o in range(n):
            b.append(P_list[a[o]])
        b = sorted(b, reverse = True)
        for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
    else:
        c.append(a[0])


    a = []
    b = []

for i in c:
    print(str(i + 1))


        
            



     
 N = int(input()) N int(input()) int input() input S_list = [] S_list [] P_list = [] P_list [] c = [] c [] for i in range(N):
    S, P = input().split()
    S_list.append(S)
    P_list.append(int(P)) i range(N) range N S, P = input().split() S input().split() ().split () input split P S_list.append(S) S_list.append S_list append S P_list.append(int(P)) P_list.append P_list append int(P) int P m = S_list m S_list m = list(set(m)) m list(set(m)) list set(m) set m m = sorted(m) m sorted(m) sorted m n = 0 n 0 a = [] a [] b = [] b [] for i in m:
    for j in range(N):
        if i == S_list[j]:
            a.append(j)
    n = len(a)
    if n != 1:
        for o in range(n):
            b.append(P_list[a[o]])
        b = sorted(b, reverse = True)
        for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
    else:
        c.append(a[0])


    a = []
    b = [] i m for j in range(N):
        if i == S_list[j]:
            a.append(j)
     j range(N) range N if i == S_list[j]:
            a.append(j)
     i == S_list[j] i S_list[j] S_list j a.append(j) a.append a append j n = len(a) n len(a) len a if n != 1:
        for o in range(n):
            b.append(P_list[a[o]])
        b = sorted(b, reverse = True)
        for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
    else:
        c.append(a[0])


     n != 1 n 1 for o in range(n):
            b.append(P_list[a[o]])
         o range(n) range n b.append(P_list[a[o]]) b.append b append P_list[a[o]] P_list a[o] a o b = sorted(b, reverse = True) b sorted(b, reverse = True) sorted b reverse = True reverse True for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
     k b for l in range(N):
                if k == P_list[l]:
                    c.append(l)
     l range(N) range N if k == P_list[l]:
                    c.append(l)
     k == P_list[l] k P_list[l] P_list l c.append(l) c.append c append l c.append(a[0]) c.append c append a[0] a 0 a = [] a [] b = [] b [] for i in c:
    print(str(i + 1))


        
            



      i c print(str(i + 1)) print str(i + 1) str i + 1 i 1 P_list = [] [] P_list P = input().split() input().split() P N = int(input()) int(input()) N b = sorted(b, reverse = True) sorted(b, reverse = True) b m = sorted(m) sorted(m) m a = [] [] a m = list(set(m)) list(set(m)) m S_list = [] [] S_list a = [] [] a c = [] [] c b = [] [] b n = 0 0 n n = len(a) len(a) n S, P = input().split() input().split() S b = [] [] b m = S_list S_list m
N = int(input())
S_list = []
P_list = []
c = []

for i in range(N):
    S, P = input().split()
    S_list.append(S)
    P_list.append(int(P))

m = S_list
m = list(set(m))
m = sorted(m)

n = 0
a = []
b = []
for i in m:
    for j in range(N):
        if i == S_list[j]:
            a.append(j)
    n = len(a)
    if n != 1:
        for o in range(n):
            b.append(P_list[a[o]])
        b = sorted(b, reverse = True)
        for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
    else:
        c.append(a[0])


    a = []
    b = []

for i in c:
    print(str(i + 1))


        
            



     

