import re
n = int(input())
R = []
for i in range(n):
    S, P = input().split()
    R.append((S, int(P),int(i+1)))

Point = []
for j in range(n):
    Point.append(R[j][0])
Point = list(sorted(set(Point)))
Point
SR = sorted(R, key=lambda x:(x[0], -int(x[1])))
for k in range(n):
    print(SR[k][2])
pass import re re n = int(input()) n int(input()) int input() input R = [] R [] for i in range(n):
    S, P = input().split()
    R.append((S, int(P),int(i+1))) i range(n) range n S, P = input().split() S input().split() ().split () input split P R.append((S, int(P),int(i+1))) R.append R append (S, int(P),int(i+1)) S int(P) int P int(i+1) int i+1 i 1 Point = [] Point [] for j in range(n):
    Point.append(R[j][0]) j range(n) range n Point.append(R[j][0]) Point.append Point append R[j][0] [j] R j 0 Point = list(sorted(set(Point))) Point list(sorted(set(Point))) list sorted(set(Point)) sorted set(Point) set Point Point SR = sorted(R, key=lambda x:(x[0], -int(x[1]))) SR sorted(R, key=lambda x:(x[0], -int(x[1]))) sorted R key=lambda x:(x[0], -int(x[1])) key lambda x:(x[0], -int(x[1])) (x[0], -int(x[1])) x[0] x 0 -int(x[1]) int(x[1]) int x[1] x 1 x for k in range(n):
    print(SR[k][2]) k range(n) range n print(SR[k][2]) print SR[k][2] [k] SR k 2 P = input().split() input().split() P Point = list(sorted(set(Point))) list(sorted(set(Point))) Point R = [] [] R SR = sorted(R, key=lambda x:(x[0], -int(x[1]))) sorted(R, key=lambda x:(x[0], -int(x[1]))) SR S, P = input().split() input().split() S Point = [] [] Point n = int(input()) int(input()) n
import re
n = int(input())
R = []
for i in range(n):
    S, P = input().split()
    R.append((S, int(P),int(i+1)))

Point = []
for j in range(n):
    Point.append(R[j][0])
Point = list(sorted(set(Point)))
Point
SR = sorted(R, key=lambda x:(x[0], -int(x[1])))
for k in range(n):
    print(SR[k][2])
pass