import math





def main():

    N = int(eval(input()))

    SP = [list(input().split()) + [i + 1] for i in range(N)]

    SP.sort(key=lambda x: (x[0], -int(x[1])))

    for i in [x[2] for x in SP]:

        print(i)





if __name__ == '__main__':

    main()

import math

import numpy as np





def main():

    N = int(eval(input()))

    SP = [list(input().split()) + [i + 1] for i in range(N)]

    SP.sort(key=lambda x: (x[0], -int(x[1])))

    _SP = np.array(SP)

    for i in _SP[:, 2]:

        print(i)





if __name__ == '__main__':

    main()

import math


def main():
    N = int(eval(input()))
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    for i in [x[2] for x in SP]:
        print(i)


if __name__ == "__main__":
    main()

import math
import numpy as np


def main():
    N = int(eval(input()))
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    _SP = np.array(SP)
    for i in _SP[:, 2]:
        print(i)


if __name__ == "__main__":
    main()

+import numpy as np -    for i in [x[2] for x in SP]: +    _SP = np.array(SP) +    for i in _SP[:, 2]: