import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


n = ni()
res = [list(input().split() + [i + 1]) for i in range(n)]
res = list(map(lambda x: (x[0], int(x[1]), x[2]), res))
res = sorted(res, key=lambda x: x[0])
start = 0
start_res = res[0][0]
sor_res = []
ans = []
for i in range(n):
    if start_res != res[i][0]:
        end = i - 1
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
        start = i
        start_res = res[i][0]
    if i == n - 1:
        end = i
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
for r in sor_res:
    print(r[2]) import sys sys stdin = sys.stdin stdin sys.stdin sys stdin def ns(): return stdin.readline().rstrip() ns def ni(): return int(stdin.readline().rstrip()) ni def nm(): return map(int, stdin.readline().split()) nm def nl(): return list(map(int, stdin.readline().split())) nl n = ni() n ni() ni list(input().split() + [i + 1]) for i in range(n) for i in range(n) i range(n) range n for i in range(n) list(input().split() + [i + 1]) list input().split() + [i + 1] input().split() ().split () input split [i + 1] i + 1 i 1 res = [list(input().split() + [i + 1]) for i in range(n)] res [list(input().split() + [i + 1]) for i in range(n)] res = list(map(lambda x: (x[0], int(x[1]), x[2]), res)) res list(map(lambda x: (x[0], int(x[1]), x[2]), res)) list map(lambda x: (x[0], int(x[1]), x[2]), res) map lambda x: (x[0], int(x[1]), x[2]) (x[0], int(x[1]), x[2]) x[0] x 0 int(x[1]) int x[1] x 1 x[2] x 2 x res res = sorted(res, key=lambda x: x[0]) res sorted(res, key=lambda x: x[0]) sorted res key=lambda x: x[0] key lambda x: x[0] x[0] x 0 x start = 0 start 0 start_res = res[0][0] start_res res[0][0] [0] res 0 0 sor_res = [] sor_res [] ans = [] ans [] for i in range(n):
    if start_res != res[i][0]:
        end = i - 1
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
        start = i
        start_res = res[i][0]
    if i == n - 1:
        end = i
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) i range(n) range n if start_res != res[i][0]:
        end = i - 1
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
        start = i
        start_res = res[i][0]
     start_res != res[i][0] start_res res[i][0] [i] res i 0 end = i - 1 end i - 1 i 1 sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) sor_res sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) sorted res[start:end + 1] res start:end + 1 start end + 1 end 1 key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True start = i start i start_res = res[i][0] start_res res[i][0] [i] res i 0 if i == n - 1:
        end = i
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) i == n - 1 i n - 1 n 1 end = i end i sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) sor_res sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) sorted res[start:end + 1] res start:end + 1 start end + 1 end 1 key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True for r in sor_res:
    print(r[2]) r sor_res print(r[2]) print r[2] r 2 sor_res = [] [] sor_res end = i - 1 i - 1 end def ns(): return stdin.readline().rstrip() def ns(): return stdin.readline().rstrip() ns n = ni() ni() n res = sorted(res, key=lambda x: x[0]) sorted(res, key=lambda x: x[0]) res sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) sor_res def nl(): return list(map(int, stdin.readline().split())) def nl(): return list(map(int, stdin.readline().split())) nl ans = [] [] ans start = 0 0 start start_res = res[i][0] res[i][0] start_res stdin = sys.stdin sys.stdin stdin start_res = res[0][0] res[0][0] start_res def ni(): return int(stdin.readline().rstrip()) def ni(): return int(stdin.readline().rstrip()) ni def nm(): return map(int, stdin.readline().split()) def nm(): return map(int, stdin.readline().split()) nm end = i i end sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) sorted(res[start:end + 1], key=lambda x: x[1], reverse=True) sor_res res = list(map(lambda x: (x[0], int(x[1]), x[2]), res)) list(map(lambda x: (x[0], int(x[1]), x[2]), res)) res start = i i start res = [list(input().split() + [i + 1]) for i in range(n)] [list(input().split() + [i + 1]) for i in range(n)] res
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


n = ni()
res = [list(input().split() + [i + 1]) for i in range(n)]
res = list(map(lambda x: (x[0], int(x[1]), x[2]), res))
res = sorted(res, key=lambda x: x[0])
start = 0
start_res = res[0][0]
sor_res = []
ans = []
for i in range(n):
    if start_res != res[i][0]:
        end = i - 1
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
        start = i
        start_res = res[i][0]
    if i == n - 1:
        end = i
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
for r in sor_res:
    print(r[2])
