def mapt(fn, *args):
    return list(map(fn, *args))


def Atom(segment):
    try:
        return int(segment)
    except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment


def Input():
    return mapt(int, input().split(" "))


def main():
    n = int(input())
    data = [mapt(Atom, input().split(" ")) for _ in range(n)]
    for i in range(n):
        data[i].append(i)
    data = sorted(data, key=lambda x:x[1], reverse=True)
    data = sorted(data, key = lambda x:x[0])
    for row in data:
        print(row[2]+1)

main() def mapt(fn, *args):
    return list(map(fn, *args)) mapt return list(map(fn, *args)) list(map(fn, *args)) list map(fn, *args) map fn *args args fn fn *args def Atom(segment):
    try:
        return int(segment)
    except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment Atom try:
        return int(segment)
    except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment try:
            float(segment)
        except ValueError:
            return segment except ValueError:
            return segment return segment segment float(segment) float segment return int(segment) int(segment) int segment segment segment def Input():
    return mapt(int, input().split(" ")) Input return mapt(int, input().split(" ")) mapt(int, input().split(" ")) mapt int input().split(" ") ().split () input split " " def main():
    n = int(input())
    data = [mapt(Atom, input().split(" ")) for _ in range(n)]
    for i in range(n):
        data[i].append(i)
    data = sorted(data, key=lambda x:x[1], reverse=True)
    data = sorted(data, key = lambda x:x[0])
    for row in data:
        print(row[2]+1) main n = int(input()) n int(input()) int input() input mapt(Atom, input().split(" ")) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) mapt(Atom, input().split(" ")) mapt Atom input().split(" ") ().split () input split " " data = [mapt(Atom, input().split(" ")) for _ in range(n)] data [mapt(Atom, input().split(" ")) for _ in range(n)] for i in range(n):
        data[i].append(i)
     i range(n) range n data[i].append(i) [i].append [i] data i append i data = sorted(data, key=lambda x:x[1], reverse=True) data sorted(data, key=lambda x:x[1], reverse=True) sorted data key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True data = sorted(data, key = lambda x:x[0]) data sorted(data, key = lambda x:x[0]) sorted data key = lambda x:x[0] key lambda x:x[0] x[0] x 0 x for row in data:
        print(row[2]+1) row data print(row[2]+1) print row[2]+1 row[2] row 2 1 main() main def main():
    n = int(input())
    data = [mapt(Atom, input().split(" ")) for _ in range(n)]
    for i in range(n):
        data[i].append(i)
    data = sorted(data, key=lambda x:x[1], reverse=True)
    data = sorted(data, key = lambda x:x[0])
    for row in data:
        print(row[2]+1) def main():
    n = int(input())
    data = [mapt(Atom, input().split(" ")) for _ in range(n)]
    for i in range(n):
        data[i].append(i)
    data = sorted(data, key=lambda x:x[1], reverse=True)
    data = sorted(data, key = lambda x:x[0])
    for row in data:
        print(row[2]+1) main def Atom(segment):
    try:
        return int(segment)
    except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment def Atom(segment):
    try:
        return int(segment)
    except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment Atom def Input():
    return mapt(int, input().split(" ")) def Input():
    return mapt(int, input().split(" ")) Input def mapt(fn, *args):
    return list(map(fn, *args)) def mapt(fn, *args):
    return list(map(fn, *args)) mapt
def mapt(fn, *args):
    return list(map(fn, *args))


def Atom(segment):
    try:
        return int(segment)
    except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment


def Input():
    return mapt(int, input().split(" "))


def main():
    n = int(input())
    data = [mapt(Atom, input().split(" ")) for _ in range(n)]
    for i in range(n):
        data[i].append(i)
    data = sorted(data, key=lambda x:x[1], reverse=True)
    data = sorted(data, key = lambda x:x[0])
    for row in data:
        print(row[2]+1)

main()