import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
d = []
for i in range(N):
    s, p = ins().split()
    p = int(p)
    d.append((s, -p, i + 1))
d.sort()


def solve():
    for _, _, i in d:
        print(i)


solve() import sys sys sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 ini = lambda: int(sys.stdin.readline()) ini lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline inm = lambda: map(int, sys.stdin.readline().split()) inm lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split inl = lambda: list(inm()) inl lambda: list(inm()) list(inm()) list inm() inm ins = lambda: sys.stdin.readline().rstrip() ins lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) debug lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) print "\033[33m" *a a "\033[0m" **dict(file=sys.stderr, **kw) dict(file=sys.stderr, **kw) dict file=sys.stderr file sys.stderr sys stderr **kw kw *a **kw N = ini() N ini() ini d = [] d [] for i in range(N):
    s, p = ins().split()
    p = int(p)
    d.append((s, -p, i + 1)) i range(N) range N s, p = ins().split() s ins().split() ().split () ins split p p = int(p) p int(p) int p d.append((s, -p, i + 1)) d.append d append (s, -p, i + 1) s -p p i + 1 i 1 d.sort() d.sort d sort def solve():
    for _, _, i in d:
        print(i) solve for _, _, i in d:
        print(i) _ _ i d print(i) print i solve() solve d = [] [] d s, p = ins().split() ins().split() s debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) debug ins = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() ins p = ins().split() ins().split() p ini = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ini inm = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) inm inl = lambda: list(inm()) lambda: list(inm()) inl N = ini() ini() N p = int(p) int(p) p def solve():
    for _, _, i in d:
        print(i) def solve():
    for _, _, i in d:
        print(i) solve
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
d = []
for i in range(N):
    s, p = ins().split()
    p = int(p)
    d.append((s, -p, i + 1))
d.sort()


def solve():
    for _, _, i in d:
        print(i)


solve()
