def solve():

  n = int(eval(input()))

  query = []

  for i in range(n):

    tmp = eval(input())

    s,p = tmp.split()

    query.append((s,p,i+1))

  query.sort()

  count = 0

  while count<1000:

    count += 1

    for i in range(n):

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

        if query[i][0] == query[j][0]:

          if int(query[i][1]) <int(query[j][1]):

            buf = query[i]

            query[i] = query[j]

            query[j] = buf

            

    

  for i in range(n):

    print((query[i][2]))

solve()
def solve():

  n = int(eval(input()))

  query = []

  for i in range(n):

    tmp = eval(input())

    s,p = tmp.split()

    query.append((s,p,i+1))

  query.sort()

  count = 0

  while count<n:

    count += 1

    for i in range(n):

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

        if query[i][0] == query[j][0]:

          if int(query[i][1]) <int(query[j][1]):

            buf = query[i]

            query[i] = query[j]

            query[j] = buf

            

    

  for i in range(n):

    print((query[i][2]))

solve()
def solve():
    n = int(eval(input()))
    query = []
    for i in range(n):
        tmp = eval(input())
        s, p = tmp.split()
        query.append((s, p, i + 1))
    query.sort()
    count = 0
    while count < 1000:
        count += 1
        for i in range(n):
            for j in range(i + 1, n):
                if query[i][0] == query[j][0]:
                    if int(query[i][1]) < int(query[j][1]):
                        buf = query[i]
                        query[i] = query[j]
                        query[j] = buf
    for i in range(n):
        print((query[i][2]))


solve()

def solve():
    n = int(eval(input()))
    query = []
    for i in range(n):
        tmp = eval(input())
        s, p = tmp.split()
        query.append((s, p, i + 1))
    query.sort()
    count = 0
    while count < n:
        count += 1
        for i in range(n):
            for j in range(i + 1, n):
                if query[i][0] == query[j][0]:
                    if int(query[i][1]) < int(query[j][1]):
                        buf = query[i]
                        query[i] = query[j]
                        query[j] = buf
    for i in range(n):
        print((query[i][2]))


solve()

-    while count < 1000: +    while count < n: