import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
SP = []
for i in range(N):
	s =rs()
	S, P = s.split(' ')
	P = int(P)
	SP.append((S, -P, i+1))

SP.sort()
for s, p, n in SP:
	print(n) import sys, math sys math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline rs = lambda: input().strip() rs lambda: input().strip() input().strip() ().strip () input strip ri = lambda: int(input()) ri lambda: int(input()) int(input()) int input() input rl = lambda: list(map(int, input().split())) rl lambda: list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split mod = 1000000007 mod 1000000007 sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 N = ri() N ri() ri SP = [] SP [] for i in range(N):
	s =rs()
	S, P = s.split(' ')
	P = int(P)
	SP.append((S, -P, i+1)) i range(N) range N s =rs() s rs() rs S, P = s.split(' ') S s.split(' ') s.split s split ' ' P P = int(P) P int(P) int P SP.append((S, -P, i+1)) SP.append SP append (S, -P, i+1) S -P P i+1 i 1 SP.sort() SP.sort SP sort for s, p, n in SP:
	print(n) s p n SP print(n) print n s =rs() rs() s P = int(P) int(P) P ri = lambda: int(input()) lambda: int(input()) ri input = sys.stdin.readline sys.stdin.readline input N = ri() ri() N SP = [] [] SP P = s.split(' ') s.split(' ') P S, P = s.split(' ') s.split(' ') S rl = lambda: list(map(int, input().split())) lambda: list(map(int, input().split())) rl rs = lambda: input().strip() lambda: input().strip() rs mod = 1000000007 1000000007 mod
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
SP = []
for i in range(N):
	s =rs()
	S, P = s.split(' ')
	P = int(P)
	SP.append((S, -P, i+1))

SP.sort()
for s, p, n in SP:
	print(n)
