

def comp_rest(a,b):

    if a[0] > b[0]:

        return True

    elif a[0] < b[0]:

        return False

    elif a[0] == b[0]:

        return a[1] < b[1]



def solve():

    N = int(input())

    SP = []

    for i in range(N):

        SiPi = input().split()

        Si = SiPi[0]

        Pi = int(SiPi[1])

        SP.append([Si, Pi, i+1])

    for i in range(N):

        for j in range(i+1, N):

            if comp_rest(SP[i], SP[j]):

                SP[i], SP[j] = SP[j], SP[i]

    for i in range(N):

        print(SP[i][2])



if __name__ == '__main__':

    solve()

def solve():

    N = int(input())

    SP = []

    for i in range(N):

        SiPi = input().split()

        Si = SiPi[0]

        Pi = int(SiPi[1])

        SP.append([Si, - Pi, i+1])

    SP.sort()

    for i in range(N):

        print(SP[i][2])



if __name__ == '__main__':

    solve()

def comp_rest(a, b):
    if a[0] > b[0]:
        return True
    elif a[0] < b[0]:
        return False
    elif a[0] == b[0]:
        return a[1] < b[1]


def solve():
    N = int(input())
    SP = []
    for i in range(N):
        SiPi = input().split()
        Si = SiPi[0]
        Pi = int(SiPi[1])
        SP.append([Si, Pi, i + 1])
    for i in range(N):
        for j in range(i + 1, N):
            if comp_rest(SP[i], SP[j]):
                SP[i], SP[j] = SP[j], SP[i]
    for i in range(N):
        print(SP[i][2])


if __name__ == "__main__":
    solve()

def solve():
    N = int(input())
    SP = []
    for i in range(N):
        SiPi = input().split()
        Si = SiPi[0]
        Pi = int(SiPi[1])
        SP.append([Si, -Pi, i + 1])
    SP.sort()
    for i in range(N):
        print(SP[i][2])


if __name__ == "__main__":
    solve()

-def comp_rest(a, b): -    if a[0] > b[0]: -        return True -    elif a[0] < b[0]: -        return False -    elif a[0] == b[0]: -        return a[1] < b[1] - - -        SP.append([Si, Pi, i + 1]) -    for i in range(N): -        for j in range(i + 1, N): -            if comp_rest(SP[i], SP[j]): -                SP[i], SP[j] = SP[j], SP[i] +        SP.append([Si, -Pi, i + 1]) +    SP.sort()