# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    data = {}

    for i in range(n):
        row = [x for x in input().rstrip().split(" ")]
        s = row[0]
        p = int(row[1])

        if s not in data.keys():
            data[s] = {}

        data[s][p] = i+1

    for city, res in sorted(data.items()):
        for point, num in sorted(res.items(), reverse=True):
            print(num)





if __name__ == "__main__":
    resolve() def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    data = {}

    for i in range(n):
        row = [x for x in input().rstrip().split(" ")]
        s = row[0]
        p = int(row[1])

        if s not in data.keys():
            data[s] = {}

        data[s][p] = i+1

    for city, res in sorted(data.items()):
        for point, num in sorted(res.items(), reverse=True):
            print(num) resolve import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n = int(input().rstrip()) n int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip data = {} data {} for i in range(n):
        row = [x for x in input().rstrip().split(" ")]
        s = row[0]
        p = int(row[1])

        if s not in data.keys():
            data[s] = {}

        data[s][p] = i+1

     i range(n) range n x for x in input().rstrip().split(" ") for x in input().rstrip().split(" ") x input().rstrip().split(" ") ().rstrip().split ().rstrip() ().rstrip () input rstrip split " " for x in input().rstrip().split(" ") x row = [x for x in input().rstrip().split(" ")] row [x for x in input().rstrip().split(" ")] s = row[0] s row[0] row 0 p = int(row[1]) p int(row[1]) int row[1] row 1 if s not in data.keys():
            data[s] = {}

         s not in data.keys() s data.keys() data.keys data keys data[s] = {} data[s] data s {} data[s][p] = i+1 data[s][p] [s] data s p i+1 i 1 for city, res in sorted(data.items()):
        for point, num in sorted(res.items(), reverse=True):
            print(num) city res sorted(data.items()) sorted data.items() data.items data items for point, num in sorted(res.items(), reverse=True):
            print(num) point num sorted(res.items(), reverse=True) sorted res.items() res.items res items reverse=True reverse True print(num) print num if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    data = {}

    for i in range(n):
        row = [x for x in input().rstrip().split(" ")]
        s = row[0]
        p = int(row[1])

        if s not in data.keys():
            data[s] = {}

        data[s][p] = i+1

    for city, res in sorted(data.items()):
        for point, num in sorted(res.items(), reverse=True):
            print(num) def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    data = {}

    for i in range(n):
        row = [x for x in input().rstrip().split(" ")]
        s = row[0]
        p = int(row[1])

        if s not in data.keys():
            data[s] = {}

        data[s][p] = i+1

    for city, res in sorted(data.items()):
        for point, num in sorted(res.items(), reverse=True):
            print(num) resolve
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    data = {}

    for i in range(n):
        row = [x for x in input().rstrip().split(" ")]
        s = row[0]
        p = int(row[1])

        if s not in data.keys():
            data[s] = {}

        data[s][p] = i+1

    for city, res in sorted(data.items()):
        for point, num in sorted(res.items(), reverse=True):
            print(num)





if __name__ == "__main__":
    resolve()
