# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    r = []
    for i in range(n):
        s, x = [x for x in input().split()]
        r.append((s, - int(x), i + 1))
    r.sort()
    for e in r:
        print(e[2])

    



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

""" import sys sys from collections import deque, defaultdict from math import sqrt, factorial def solve():
    n = int(input())
    r = []
    for i in range(n):
        s, x = [x for x in input().split()]
        r.append((s, - int(x), i + 1))
    r.sort()
    for e in r:
        print(e[2])

     solve n = int(input()) n int(input()) int input() input r = [] r [] for i in range(n):
        s, x = [x for x in input().split()]
        r.append((s, - int(x), i + 1))
     i range(n) range n x for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() x s, x = [x for x in input().split()] s [x for x in input().split()] x r.append((s, - int(x), i + 1)) r.append r append (s, - int(x), i + 1) s - int(x) int(x) int x i + 1 i 1 r.sort() r.sort r sort for e in r:
        print(e[2])

     e r print(e[2]) print e[2] e 2 t = 1 t 1 for case in range(1,t+1):
    ans = solve() case range(1,t+1) range 1 t+1 t 1 ans = solve() ans solve() solve """

""" def solve():
    n = int(input())
    r = []
    for i in range(n):
        s, x = [x for x in input().split()]
        r.append((s, - int(x), i + 1))
    r.sort()
    for e in r:
        print(e[2])

     def solve():
    n = int(input())
    r = []
    for i in range(n):
        s, x = [x for x in input().split()]
        r.append((s, - int(x), i + 1))
    r.sort()
    for e in r:
        print(e[2])

     solve ans = solve() solve() ans t = 1 1 t
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    r = []
    for i in range(n):
        s, x = [x for x in input().split()]
        r.append((s, - int(x), i + 1))
    r.sort()
    for e in r:
        print(e[2])

    



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

"""
