import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
d = [LS() + [str(i)] for i in range(1, n+1)]
d = sorted(d, key=lambda x: (x[0], int(x[1])*(-1)))
for elem in d:
    print(elem[2]) import sys sys def input(): return sys.stdin.readline().strip() input def I(): return int(input()) I def LI(): return list(map(int, input().split())) LI I() for i in range(n) for i in range(n) i range(n) range n for i in range(n) I() I def IR(n): return [I() for i in range(n)] IR n n LI() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LI() LI def LIR(n): return [LI() for i in range(n)] LIR n n S() for i in range(n) for i in range(n) i range(n) range n for i in range(n) S() S def SR(n): return [S() for i in range(n)] SR n n def S(): return input() S def LS(): return input().split() LS INF = float('inf') INF float('inf') float 'inf' n = I() n I() I LS() + [str(i)] for i in range(1, n+1) for i in range(1, n+1) i range(1, n+1) range 1 n+1 n 1 for i in range(1, n+1) LS() + [str(i)] LS() LS [str(i)] str(i) str i d = [LS() + [str(i)] for i in range(1, n+1)] d [LS() + [str(i)] for i in range(1, n+1)] d = sorted(d, key=lambda x: (x[0], int(x[1])*(-1))) d sorted(d, key=lambda x: (x[0], int(x[1])*(-1))) sorted d key=lambda x: (x[0], int(x[1])*(-1)) key lambda x: (x[0], int(x[1])*(-1)) (x[0], int(x[1])*(-1)) x[0] x 0 int(x[1])*(-1) int(x[1]) int x[1] x 1 -1 x for elem in d:
    print(elem[2]) elem d print(elem[2]) print elem[2] elem 2 def IR(n): return [I() for i in range(n)] def IR(n): return [I() for i in range(n)] IR def LS(): return input().split() def LS(): return input().split() LS d = sorted(d, key=lambda x: (x[0], int(x[1])*(-1))) sorted(d, key=lambda x: (x[0], int(x[1])*(-1))) d def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input def I(): return int(input()) def I(): return int(input()) I def S(): return input() def S(): return input() S INF = float('inf') float('inf') INF def SR(n): return [S() for i in range(n)] def SR(n): return [S() for i in range(n)] SR def LIR(n): return [LI() for i in range(n)] def LIR(n): return [LI() for i in range(n)] LIR n = I() I() n def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI d = [LS() + [str(i)] for i in range(1, n+1)] [LS() + [str(i)] for i in range(1, n+1)] d
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
d = [LS() + [str(i)] for i in range(1, n+1)]
d = sorted(d, key=lambda x: (x[0], int(x[1])*(-1)))
for elem in d:
    print(elem[2])
