if __name__ == '__main__':

	n = int(input())

	A = []
	for i in range(n):
		cmd = input().split()
		A.append([i+1,cmd[0],int(cmd[1])])

	B = sorted(A,key=lambda x:(x[1],-x[2]))
	for j in B:
		print(j[0]) if __name__ == '__main__':

	n = int(input())

	A = []
	for i in range(n):
		cmd = input().split()
		A.append([i+1,cmd[0],int(cmd[1])])

	B = sorted(A,key=lambda x:(x[1],-x[2]))
	for j in B:
		print(j[0]) __name__ == '__main__' __name__ '__main__' n = int(input()) n int(input()) int input() input A = [] A [] for i in range(n):
		cmd = input().split()
		A.append([i+1,cmd[0],int(cmd[1])])

	 i range(n) range n cmd = input().split() cmd input().split() ().split () input split A.append([i+1,cmd[0],int(cmd[1])]) A.append A append [i+1,cmd[0],int(cmd[1])] i+1 i 1 cmd[0] cmd 0 int(cmd[1]) int cmd[1] cmd 1 B = sorted(A,key=lambda x:(x[1],-x[2])) B sorted(A,key=lambda x:(x[1],-x[2])) sorted A key=lambda x:(x[1],-x[2]) key lambda x:(x[1],-x[2]) (x[1],-x[2]) x[1] x 1 -x[2] x[2] x 2 x for j in B:
		print(j[0]) j B print(j[0]) print j[0] j 0 A = [] [] A n = int(input()) int(input()) n cmd = input().split() input().split() cmd B = sorted(A,key=lambda x:(x[1],-x[2])) sorted(A,key=lambda x:(x[1],-x[2])) B
if __name__ == '__main__':

	n = int(input())

	A = []
	for i in range(n):
		cmd = input().split()
		A.append([i+1,cmd[0],int(cmd[1])])

	B = sorted(A,key=lambda x:(x[1],-x[2]))
	for j in B:
		print(j[0])
