import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

import collections
d = collections.defaultdict(list)

for i in range(N):
    S, P = input().split()
    P = int(P)
    d[S].append((i+1, P))

ordered = list(d.keys())
ordered.sort()

for city in ordered:
    mises = d[city]
    mises = sorted(mises, key=lambda x: x[1], reverse=True)
    for mise in mises:
        print(mise[0]) import sys sys readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 INF = float('inf') INF float('inf') float 'inf' N = int(input()) N int(input()) int input() input import collections collections d = collections.defaultdict(list) d collections.defaultdict(list) collections.defaultdict collections defaultdict list for i in range(N):
    S, P = input().split()
    P = int(P)
    d[S].append((i+1, P)) i range(N) range N S, P = input().split() S input().split() ().split () input split P P = int(P) P int(P) int P d[S].append((i+1, P)) [S].append [S] d S append (i+1, P) i+1 i 1 P ordered = list(d.keys()) ordered list(d.keys()) list d.keys() d.keys d keys ordered.sort() ordered.sort ordered sort for city in ordered:
    mises = d[city]
    mises = sorted(mises, key=lambda x: x[1], reverse=True)
    for mise in mises:
        print(mise[0]) city ordered mises = d[city] mises d[city] d city mises = sorted(mises, key=lambda x: x[1], reverse=True) mises sorted(mises, key=lambda x: x[1], reverse=True) sorted mises key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True for mise in mises:
        print(mise[0]) mise mises print(mise[0]) print mise[0] mise 0 readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines N = int(input()) int(input()) N P = int(P) int(P) P d = collections.defaultdict(list) collections.defaultdict(list) d read = sys.stdin.buffer.read sys.stdin.buffer.read read INF = float('inf') float('inf') INF S, P = input().split() input().split() S P = input().split() input().split() P ordered = list(d.keys()) list(d.keys()) ordered mises = sorted(mises, key=lambda x: x[1], reverse=True) sorted(mises, key=lambda x: x[1], reverse=True) mises mises = d[city] d[city] mises readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

import collections
d = collections.defaultdict(list)

for i in range(N):
    S, P = input().split()
    P = int(P)
    d[S].append((i+1, P))

ordered = list(d.keys())
ordered.sort()

for city in ordered:
    mises = d[city]
    mises = sorted(mises, key=lambda x: x[1], reverse=True)
    for mise in mises:
        print(mise[0])