

# import numpy as np

# import numpypy as np

import sys

input = sys.stdin.readline



def eprint(*args, **kwargs):

    print(*args, file=sys.stderr, **kwargs)



import math

import string

import fractions

import re

import array

import copy

import functools

import operator



import collections

import itertools

import bisect

import heapq





from heapq import heappush

from heapq import heappop



# from itertools import accumulate

# from collections import deque

import random





def main():

    n = int(eval(input()))

    dict={}

    for i in range(n):

        name, score= input().split()

        if not(name in dict):

            dict[name]=[((int(score),i+1))]

        else:

            dict[name].append((int(score),i+1))

            dict[name].sort(reverse=True)

    eprint(dict)

    ll=list(dict.items())

    eprint(ll)

    ll.sort()

    eprint(ll)

    for x in ll:

        for y in x[1]:

            print(y[1])

        

if __name__ == '__main__':

    main()



# import numpy as np

# import numpypy as np

import sys

input = sys.stdin.readline



def eprint(*args, **kwargs):

    print(*args, file=sys.stderr, **kwargs)



# import math

# import string

# import fractions

# from fractions import Fraction

# from fractions import gcd

# def lcm(n,m):

#     return int(n*m/gcd(n,m))



# import re

# # import array

# import copy

# import functools

# import operator



# import collections

# import itertools

# import bisect

# import heapq





# from heapq import heappush

# from heapq import heappop



# # from itertools import accumulate

# # from collections import deque

# import random



from queue import PriorityQueue as pq

# class ReversePriorityQueue(PriorityQueue):

#     def __cmp__(self, other):

#         return -cmp(self.degree, other.degree)

#     # def put(self, tup):

    #     newtup = tup[0] * -1, tup[1]

    #     PriorityQueue.put(self, newtup)



    # def get(self):

    #     tup = PriorityQueue.get(self)

    #     newtup = tup[0] * -1, tup[1]

    #     return newtup



def main():

    n = int(eval(input()))

    dict={}

    for i in range(1,n+1):

        str_x,num = input().split()

        num =int(num)

        if (str_x in dict):

            dict[str_x].put((-num,i))

            # dict[str_x].sort(key = lambda x : x[1])

        else:

            a=pq()

            dict[str_x]=a

            dict[str_x].put((-num,i))

            # a.put([num,i])

    eprint(dict)

    ll = sorted(list(dict.items()))

    eprint(ll)

    # for i in ll:

    #     for j in i[1]:

    #         print(j[1])

    for item in ll:

        while item[1].qsize():

            print((item[1].get())[1])

if __name__ == '__main__':

    main()

# import numpy as np
# import numpypy as np
import sys

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


import math
import string
import fractions
import re
import array
import copy
import functools
import operator
import collections
import itertools
import bisect
import heapq
from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random


def main():
    n = int(eval(input()))
    dict = {}
    for i in range(n):
        name, score = input().split()
        if not (name in dict):
            dict[name] = [((int(score), i + 1))]
        else:
            dict[name].append((int(score), i + 1))
            dict[name].sort(reverse=True)
    eprint(dict)
    ll = list(dict.items())
    eprint(ll)
    ll.sort()
    eprint(ll)
    for x in ll:
        for y in x[1]:
            print(y[1])


if __name__ == "__main__":
    main()

# import numpy as np
# import numpypy as np
import sys

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd
# def lcm(n,m):
#     return int(n*m/gcd(n,m))
# import re
# # import array
# import copy
# import functools
# import operator
# import collections
# import itertools
# import bisect
# import heapq
# from heapq import heappush
# from heapq import heappop
# # from itertools import accumulate
# # from collections import deque
# import random
from queue import PriorityQueue as pq

# class ReversePriorityQueue(PriorityQueue):
#     def __cmp__(self, other):
#         return -cmp(self.degree, other.degree)
#     # def put(self, tup):
#     newtup = tup[0] * -1, tup[1]
#     PriorityQueue.put(self, newtup)
# def get(self):
#     tup = PriorityQueue.get(self)
#     newtup = tup[0] * -1, tup[1]
#     return newtup
def main():
    n = int(eval(input()))
    dict = {}
    for i in range(1, n + 1):
        str_x, num = input().split()
        num = int(num)
        if str_x in dict:
            dict[str_x].put((-num, i))
            # dict[str_x].sort(key = lambda x : x[1])
        else:
            a = pq()
            dict[str_x] = a
            dict[str_x].put((-num, i))
            # a.put([num,i])
    eprint(dict)
    ll = sorted(list(dict.items()))
    eprint(ll)
    # for i in ll:
    #     for j in i[1]:
    #         print(j[1])
    for item in ll:
        while item[1].qsize():
            print((item[1].get())[1])


if __name__ == "__main__":
    main()

-import math -import string -import fractions -import re -import array -import copy -import functools -import operator -import collections -import itertools -import bisect -import heapq -from heapq import heappush -from heapq import heappop +# import math +# import string +# import fractions +# from fractions import Fraction +# from fractions import gcd +# def lcm(n,m): +#     return int(n*m/gcd(n,m)) +# import re +# # import array +# import copy +# import functools +# import operator +# import collections +# import itertools +# import bisect +# import heapq +# from heapq import heappush +# from heapq import heappop +# # from itertools import accumulate +# # from collections import deque +# import random +from queue import PriorityQueue as pq -# from itertools import accumulate -# from collections import deque -import random - - +# class ReversePriorityQueue(PriorityQueue): +#     def __cmp__(self, other): +#         return -cmp(self.degree, other.degree) +#     # def put(self, tup): +#     newtup = tup[0] * -1, tup[1] +#     PriorityQueue.put(self, newtup) +# def get(self): +#     tup = PriorityQueue.get(self) +#     newtup = tup[0] * -1, tup[1] +#     return newtup -    for i in range(n): -        name, score = input().split() -        if not (name in dict): -            dict[name] = [((int(score), i + 1))] +    for i in range(1, n + 1): +        str_x, num = input().split() +        num = int(num) +        if str_x in dict: +            dict[str_x].put((-num, i)) +            # dict[str_x].sort(key = lambda x : x[1]) -            dict[name].append((int(score), i + 1)) -            dict[name].sort(reverse=True) +            a = pq() +            dict[str_x] = a +            dict[str_x].put((-num, i)) +            # a.put([num,i]) -    ll = list(dict.items()) +    ll = sorted(list(dict.items())) -    ll.sort() -    eprint(ll) -    for x in ll: -        for y in x[1]: -            print(y[1]) +    # for i in ll: +    #     for j in i[1]: +    #         print(j[1]) +    for item in ll: +        while item[1].qsize(): +            print((item[1].get())[1])