import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	n=II()
	A=[]
	for i in range(1,n+1):
		a,b=input().split()
		a=a.rstrip().decode()
		b=int(b)
		A.append([a,b,i])

	A.sort(key=lambda x:x[1],reverse=True)
	A.sort(key=lambda x:x[0])

	for _,_,i in A:
		print(i)






if __name__ == "__main__":
	main() import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline def RD(): return input().rstrip().decode() RD def II(): return int(input()) II def FI(): return int(input()) FI def MI(): return map(int,input().split()) MI def MF(): return map(float,input().split()) MF def LI(): return list(map(int,input().split())) LI def LF(): return list(map(float,input().split())) LF def TI(): return tuple(map(int,input().split()))
# rstrip().decode() TI def main():
	n=II()
	A=[]
	for i in range(1,n+1):
		a,b=input().split()
		a=a.rstrip().decode()
		b=int(b)
		A.append([a,b,i])

	A.sort(key=lambda x:x[1],reverse=True)
	A.sort(key=lambda x:x[0])

	for _,_,i in A:
		print(i) main n=II() n II() II A=[] A [] for i in range(1,n+1):
		a,b=input().split()
		a=a.rstrip().decode()
		b=int(b)
		A.append([a,b,i])

	 i range(1,n+1) range 1 n+1 n 1 a,b=input().split() a input().split() ().split () input split b a=a.rstrip().decode() a a.rstrip().decode() a.rstrip().decode a.rstrip() a.rstrip a rstrip decode b=int(b) b int(b) int b A.append([a,b,i]) A.append A append [a,b,i] a b i A.sort(key=lambda x:x[1],reverse=True) A.sort A sort key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True A.sort(key=lambda x:x[0]) A.sort A sort key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x for _,_,i in A:
		print(i) _ _ i A print(i) print i if __name__ == "__main__":
	main() __name__ == "__main__" __name__ "__main__" main() main def II(): return int(input()) def II(): return int(input()) II def LI(): return list(map(int,input().split())) def LI(): return list(map(int,input().split())) LI def main():
	n=II()
	A=[]
	for i in range(1,n+1):
		a,b=input().split()
		a=a.rstrip().decode()
		b=int(b)
		A.append([a,b,i])

	A.sort(key=lambda x:x[1],reverse=True)
	A.sort(key=lambda x:x[0])

	for _,_,i in A:
		print(i) def main():
	n=II()
	A=[]
	for i in range(1,n+1):
		a,b=input().split()
		a=a.rstrip().decode()
		b=int(b)
		A.append([a,b,i])

	A.sort(key=lambda x:x[1],reverse=True)
	A.sort(key=lambda x:x[0])

	for _,_,i in A:
		print(i) main def RD(): return input().rstrip().decode() def RD(): return input().rstrip().decode() RD def MF(): return map(float,input().split()) def MF(): return map(float,input().split()) MF def MI(): return map(int,input().split()) def MI(): return map(int,input().split()) MI def TI(): return tuple(map(int,input().split()))
# rstrip().decode() def TI(): return tuple(map(int,input().split()))
# rstrip().decode() TI input = sys.stdin.buffer.readline sys.stdin.buffer.readline input def FI(): return int(input()) def FI(): return int(input()) FI def LF(): return list(map(float,input().split())) def LF(): return list(map(float,input().split())) LF
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	n=II()
	A=[]
	for i in range(1,n+1):
		a,b=input().split()
		a=a.rstrip().decode()
		b=int(b)
		A.append([a,b,i])

	A.sort(key=lambda x:x[1],reverse=True)
	A.sort(key=lambda x:x[0])

	for _,_,i in A:
		print(i)






if __name__ == "__main__":
	main()
