import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    res = dict()
    for i in range(n):
        s, n = input().split()
        if s in res:
            res[s].update({int(n): i+1})
        else:
            res[s] = {int(n): i+1}
    for i in sorted(res):
        for j in sorted(res[i].keys(), reverse=True):
            print(res[i][j])
    
if __name__ == '__main__':
    main() import sys sys input = lambda: sys.stdin.readline().rstrip() input 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 def main():
    n = int(input())
    res = dict()
    for i in range(n):
        s, n = input().split()
        if s in res:
            res[s].update({int(n): i+1})
        else:
            res[s] = {int(n): i+1}
    for i in sorted(res):
        for j in sorted(res[i].keys(), reverse=True):
            print(res[i][j])
     main n = int(input()) n int(input()) int input() input res = dict() res dict() dict for i in range(n):
        s, n = input().split()
        if s in res:
            res[s].update({int(n): i+1})
        else:
            res[s] = {int(n): i+1}
     i range(n) range n s, n = input().split() s input().split() ().split () input split n if s in res:
            res[s].update({int(n): i+1})
        else:
            res[s] = {int(n): i+1}
     s in res s res res[s].update({int(n): i+1}) [s].update [s] res s update {int(n): i+1} int(n) int(n) int n i+1 i 1 res[s] = {int(n): i+1} res[s] res s {int(n): i+1} int(n) int(n) int n i+1 i 1 for i in sorted(res):
        for j in sorted(res[i].keys(), reverse=True):
            print(res[i][j])
     i sorted(res) sorted res for j in sorted(res[i].keys(), reverse=True):
            print(res[i][j])
     j sorted(res[i].keys(), reverse=True) sorted res[i].keys() [i].keys [i] res i keys reverse=True reverse True print(res[i][j]) print res[i][j] [i] res i j if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input def main():
    n = int(input())
    res = dict()
    for i in range(n):
        s, n = input().split()
        if s in res:
            res[s].update({int(n): i+1})
        else:
            res[s] = {int(n): i+1}
    for i in sorted(res):
        for j in sorted(res[i].keys(), reverse=True):
            print(res[i][j])
     def main():
    n = int(input())
    res = dict()
    for i in range(n):
        s, n = input().split()
        if s in res:
            res[s].update({int(n): i+1})
        else:
            res[s] = {int(n): i+1}
    for i in sorted(res):
        for j in sorted(res[i].keys(), reverse=True):
            print(res[i][j])
     main
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    res = dict()
    for i in range(n):
        s, n = input().split()
        if s in res:
            res[s].update({int(n): i+1})
        else:
            res[s] = {int(n): i+1}
    for i in sorted(res):
        for j in sorted(res[i].keys(), reverse=True):
            print(res[i][j])
    
if __name__ == '__main__':
    main()