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

R2 = [{'i':i+1, 's':R[i][0], 'p':int(R[i][1])} for i in range(N)] 

S = []
for r in R:
  if r[0] not in S:
    S.append(r[0])
S.sort()

for s in S:
  rs = [r for r in R2 if r['s'] == s]
  sorted_rs = sorted(rs, key=lambda x:x['p'], reverse=True)
  for r in sorted_rs:
    print(r['i']) N = int(input()) N int(input()) int input() input input().split() for i in range(N) for i in range(N) i range(N) range N for i in range(N) input().split() ().split () input split R = [input().split() for i in range(N)] R [input().split() for i in range(N)] {'i':i+1, 's':R[i][0], 'p':int(R[i][1])} for i in range(N) for i in range(N) i range(N) range N for i in range(N) {'i':i+1, 's':R[i][0], 'p':int(R[i][1])} 'i' 'i' i+1 i 1 's' 's' R[i][0] [i] R i 0 'p' 'p' int(R[i][1]) int R[i][1] [i] R i 1 R2 = [{'i':i+1, 's':R[i][0], 'p':int(R[i][1])} for i in range(N)] R2 [{'i':i+1, 's':R[i][0], 'p':int(R[i][1])} for i in range(N)] S = [] S [] for r in R:
  if r[0] not in S:
    S.append(r[0]) r R if r[0] not in S:
    S.append(r[0]) r[0] not in S r[0] r 0 S S.append(r[0]) S.append S append r[0] r 0 S.sort() S.sort S sort for s in S:
  rs = [r for r in R2 if r['s'] == s]
  sorted_rs = sorted(rs, key=lambda x:x['p'], reverse=True)
  for r in sorted_rs:
    print(r['i']) s S r for r in R2 if r['s'] == s for r in R2 if r['s'] == s r R2 r['s'] == s r['s'] r 's' s if r['s'] == s r rs = [r for r in R2 if r['s'] == s] rs [r for r in R2 if r['s'] == s] sorted_rs = sorted(rs, key=lambda x:x['p'], reverse=True) sorted_rs sorted(rs, key=lambda x:x['p'], reverse=True) sorted rs key=lambda x:x['p'] key lambda x:x['p'] x['p'] x 'p' x reverse=True reverse True for r in sorted_rs:
    print(r['i']) r sorted_rs print(r['i']) print r['i'] r 'i' sorted_rs = sorted(rs, key=lambda x:x['p'], reverse=True) sorted(rs, key=lambda x:x['p'], reverse=True) sorted_rs R = [input().split() for i in range(N)] [input().split() for i in range(N)] R N = int(input()) int(input()) N rs = [r for r in R2 if r['s'] == s] [r for r in R2 if r['s'] == s] rs R2 = [{'i':i+1, 's':R[i][0], 'p':int(R[i][1])} for i in range(N)] [{'i':i+1, 's':R[i][0], 'p':int(R[i][1])} for i in range(N)] R2 S = [] [] S
N = int(input())
R = [input().split() for i in range(N)]

R2 = [{'i':i+1, 's':R[i][0], 'p':int(R[i][1])} for i in range(N)] 

S = []
for r in R:
  if r[0] not in S:
    S.append(r[0])
S.sort()

for s in S:
  rs = [r for r in R2 if r['s'] == s]
  sorted_rs = sorted(rs, key=lambda x:x['p'], reverse=True)
  for r in sorted_rs:
    print(r['i'])