def solver():
    N = int(input())
    ans = []
    for i in range(1, N+1):
        s, p = [n for n in input().split()]
        ans.append({'id': i, 'city': s , 'point': int(p)})
    ans_s = sorted(ans, key=lambda x: (x['city'], -x['point']))
    for j in ans_s:
        print(j['id'])

if __name__=='__main__':
    solver() def solver():
    N = int(input())
    ans = []
    for i in range(1, N+1):
        s, p = [n for n in input().split()]
        ans.append({'id': i, 'city': s , 'point': int(p)})
    ans_s = sorted(ans, key=lambda x: (x['city'], -x['point']))
    for j in ans_s:
        print(j['id']) solver N = int(input()) N int(input()) int input() input ans = [] ans [] for i in range(1, N+1):
        s, p = [n for n in input().split()]
        ans.append({'id': i, 'city': s , 'point': int(p)})
     i range(1, N+1) range 1 N+1 N 1 n for n in input().split() for n in input().split() n input().split() ().split () input split for n in input().split() n s, p = [n for n in input().split()] s [n for n in input().split()] p ans.append({'id': i, 'city': s , 'point': int(p)}) ans.append ans append {'id': i, 'city': s , 'point': int(p)} 'id' 'id' i 'city' 'city' s 'point' 'point' int(p) int p ans_s = sorted(ans, key=lambda x: (x['city'], -x['point'])) ans_s sorted(ans, key=lambda x: (x['city'], -x['point'])) sorted ans key=lambda x: (x['city'], -x['point']) key lambda x: (x['city'], -x['point']) (x['city'], -x['point']) x['city'] x 'city' -x['point'] x['point'] x 'point' x for j in ans_s:
        print(j['id']) j ans_s print(j['id']) print j['id'] j 'id' if __name__=='__main__':
    solver() __name__=='__main__' __name__ '__main__' solver() solver def solver():
    N = int(input())
    ans = []
    for i in range(1, N+1):
        s, p = [n for n in input().split()]
        ans.append({'id': i, 'city': s , 'point': int(p)})
    ans_s = sorted(ans, key=lambda x: (x['city'], -x['point']))
    for j in ans_s:
        print(j['id']) def solver():
    N = int(input())
    ans = []
    for i in range(1, N+1):
        s, p = [n for n in input().split()]
        ans.append({'id': i, 'city': s , 'point': int(p)})
    ans_s = sorted(ans, key=lambda x: (x['city'], -x['point']))
    for j in ans_s:
        print(j['id']) solver
def solver():
    N = int(input())
    ans = []
    for i in range(1, N+1):
        s, p = [n for n in input().split()]
        ans.append({'id': i, 'city': s , 'point': int(p)})
    ans_s = sorted(ans, key=lambda x: (x['city'], -x['point']))
    for j in ans_s:
        print(j['id'])

if __name__=='__main__':
    solver()
