# abc128_b.py
# https://atcoder.jp/contests/abc128/tasks/abc128_b

# B - Guidebook /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# あなたは美味しいレストランを紹介する本を書くことにしました。 
# あなたは N個のレストラン、レストラン 1、レストラン 2、…、レストラン N を紹介しようとしています。
# レストラン i は Si 市にあり、あなたは 100 点満点中 Pi 点と評価しています。 
# 異なる 2個のレストランに同じ点数がついていることはありません。
# この本では、次のような順でレストランを紹介しようとしています。
#     市名が辞書順で早いものから紹介していく。
#     同じ市に複数レストランがある場合は、点数が高いものから紹介していく。
# この本で紹介される順にレストランの番号を出力してください。

# 制約
#     1≤N≤100
#     Sは英小文字のみからなる長さ 1 以上 10以下の文字列
#     0≤Pi≤100
#     Piは整数
#     Pi≠Pj(1≤i<j≤N)

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# S1 P1
# :
# SN PN

# 出力
# N行出力せよ。i 行目 (1≤i≤N) には、i番目に紹介されるレストランの番号を出力せよ。

# 入力例 1
# 6
# khabarovsk 20
# moscow 10
# kazan 50
# kazan 35
# moscow 60
# khabarovsk 40

# 出力例 1
# 3
# 4
# 6
# 1
# 5
# 2

# 3種類の市名は辞書順で kazan < khabarovsk < moscow です。 
# それぞれの市について、点数が高いレストランから順に紹介されていきます。
# よって、レストランは 3,4,6,1,5,2の順に紹介されていきます。

# 入力例 2
# 10
# yakutsk 10
# yakutsk 20
# yakutsk 30
# yakutsk 40
# yakutsk 50
# yakutsk 60
# yakutsk 70
# yakutsk 80
# yakutsk 90
# yakutsk 100

# 出力例 2
# 10
# 9
# 8
# 7
# 6
# 5
# 4
# 3
# 2
# 1


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # A, P = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    tmps1 = list()
    tmps2 = list()
    for i in range(1, N+1):
        s, p = lines[i].split()
        # 整形
        tmp = (s+(' ')*10)[:11] + str(200-int(p))
        tmps1.append(tmp)
        tmps2.append(tmp)
    tmps1.sort()

    results = list()
    for tmp1 in tmps1:
        for i in range(N):
            if tmps2[i] == tmp1:
                results.append(i+1)

    return results


# 引数を取得
def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40']
        lines_export = [3, 4, 6, 1, 5, 2]
    if pattern == 2:
        lines_input = ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100']
        lines_export = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main() global FLAG_LOG FLAG_LOG = False FLAG_LOG False def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value)) log if FLAG_LOG:
        print(str(value)) FLAG_LOG print(str(value)) print str(value) str value value value def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # A, P = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    tmps1 = list()
    tmps2 = list()
    for i in range(1, N+1):
        s, p = lines[i].split()
        # 整形
        tmp = (s+(' ')*10)[:11] + str(200-int(p))
        tmps1.append(tmp)
        tmps2.append(tmp)
    tmps1.sort()

    results = list()
    for tmp1 in tmps1:
        for i in range(N):
            if tmps2[i] == tmp1:
                results.append(i+1)

    return results


# 引数を取得 calculation N = int(lines[0]) N int(lines[0]) int lines[0] lines 0 tmps1 = list() tmps1 list() list tmps2 = list() tmps2 list() list for i in range(1, N+1):
        s, p = lines[i].split()
        # 整形
        tmp = (s+(' ')*10)[:11] + str(200-int(p))
        tmps1.append(tmp)
        tmps2.append(tmp)
     i range(1, N+1) range 1 N+1 N 1 s, p = lines[i].split() s lines[i].split() [i].split [i] lines i split p tmp = (s+(' ')*10)[:11] + str(200-int(p)) tmp (s+(' ')*10)[:11] + str(200-int(p)) (s+(' ')*10)[:11] s+(' ')*10 s (' ')*10 ' ' 10 :11 11 str(200-int(p)) str 200-int(p) 200 int(p) int p tmps1.append(tmp) tmps1.append tmps1 append tmp tmps2.append(tmp) tmps2.append tmps2 append tmp tmps1.sort() tmps1.sort tmps1 sort results = list() results list() list for tmp1 in tmps1:
        for i in range(N):
            if tmps2[i] == tmp1:
                results.append(i+1)

     tmp1 tmps1 for i in range(N):
            if tmps2[i] == tmp1:
                results.append(i+1)

     i range(N) range N if tmps2[i] == tmp1:
                results.append(i+1)

     tmps2[i] == tmp1 tmps2[i] tmps2 i tmp1 results.append(i+1) results.append results append i+1 i 1 return results results lines lines def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ get_input_lines line = input() line input() input N = int(line) N int(line) int line lines = list() lines list() list lines.append(line) lines.append lines append line for _ in range(N):
        lines.append(input())
     _ range(N) range N lines.append(input()) lines.append lines append input() input return lines lines def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40']
        lines_export = [3, 4, 6, 1, 5, 2]
    if pattern == 2:
        lines_input = ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100']
        lines_export = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
    return lines_input, lines_export


# 動作モード判別 get_testdata if pattern == 1:
        lines_input = ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40']
        lines_export = [3, 4, 6, 1, 5, 2]
     pattern == 1 pattern 1 lines_input = ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40'] lines_input ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40'] '6' 'khabarovsk 20' 'moscow 10' 'kazan 50' 'kazan 35' 'moscow 60' 'khabarovsk 40' lines_export = [3, 4, 6, 1, 5, 2] lines_export [3, 4, 6, 1, 5, 2] 3 4 6 1 5 2 if pattern == 2:
        lines_input = ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100']
        lines_export = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
     pattern == 2 pattern 2 lines_input = ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100'] lines_input ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100'] '10' 'yakutsk 10' 'yakutsk 20' 'yakutsk 30' 'yakutsk 40' 'yakutsk 50' 'yakutsk 60' 'yakutsk 70' 'yakutsk 80' 'yakutsk 90' 'yakutsk 100' lines_export = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] lines_export [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] 10 9 8 7 6 5 4 3 2 1 return lines_input, lines_export return lines_input, lines_export lines_input lines_export pattern pattern def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理 get_mode import sys sys args = sys.argv args sys.argv sys argv global FLAG_LOG if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
     len(args) == 1 len(args) len args 1 mode = 0 mode 0 FLAG_LOG = False FLAG_LOG False mode = int(args[1]) mode int(args[1]) int args[1] args 1 FLAG_LOG = True FLAG_LOG True return mode mode def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理 main import time time started = time.time() started time.time() time.time time time mode = get_mode() mode get_mode() get_mode if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

     mode == 0 mode 0 lines_input = get_input_lines() lines_input get_input_lines() get_input_lines lines_input, lines_export = get_testdata(mode) lines_input get_testdata(mode) get_testdata mode lines_export lines_result = calculation(lines_input) lines_result calculation(lines_input) calculation lines_input for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理 line_result lines_result print(line_result) print line_result if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理 def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理 get_mode def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理 def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理 main global FLAG_LOG def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value)) def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value)) log def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # A, P = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    tmps1 = list()
    tmps2 = list()
    for i in range(1, N+1):
        s, p = lines[i].split()
        # 整形
        tmp = (s+(' ')*10)[:11] + str(200-int(p))
        tmps1.append(tmp)
        tmps2.append(tmp)
    tmps1.sort()

    results = list()
    for tmp1 in tmps1:
        for i in range(N):
            if tmps2[i] == tmp1:
                results.append(i+1)

    return results


# 引数を取得 def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # A, P = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    tmps1 = list()
    tmps2 = list()
    for i in range(1, N+1):
        s, p = lines[i].split()
        # 整形
        tmp = (s+(' ')*10)[:11] + str(200-int(p))
        tmps1.append(tmp)
        tmps2.append(tmp)
    tmps1.sort()

    results = list()
    for tmp1 in tmps1:
        for i in range(N):
            if tmps2[i] == tmp1:
                results.append(i+1)

    return results


# 引数を取得 calculation def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40']
        lines_export = [3, 4, 6, 1, 5, 2]
    if pattern == 2:
        lines_input = ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100']
        lines_export = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
    return lines_input, lines_export


# 動作モード判別 def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40']
        lines_export = [3, 4, 6, 1, 5, 2]
    if pattern == 2:
        lines_input = ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100']
        lines_export = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
    return lines_input, lines_export


# 動作モード判別 get_testdata FLAG_LOG = False False FLAG_LOG def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ get_input_lines
# abc128_b.py
# https://atcoder.jp/contests/abc128/tasks/abc128_b

# B - Guidebook /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# あなたは美味しいレストランを紹介する本を書くことにしました。 
# あなたは N個のレストラン、レストラン 1、レストラン 2、…、レストラン N を紹介しようとしています。
# レストラン i は Si 市にあり、あなたは 100 点満点中 Pi 点と評価しています。 
# 異なる 2個のレストランに同じ点数がついていることはありません。
# この本では、次のような順でレストランを紹介しようとしています。
#     市名が辞書順で早いものから紹介していく。
#     同じ市に複数レストランがある場合は、点数が高いものから紹介していく。
# この本で紹介される順にレストランの番号を出力してください。

# 制約
#     1≤N≤100
#     Sは英小文字のみからなる長さ 1 以上 10以下の文字列
#     0≤Pi≤100
#     Piは整数
#     Pi≠Pj(1≤i<j≤N)

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# S1 P1
# :
# SN PN

# 出力
# N行出力せよ。i 行目 (1≤i≤N) には、i番目に紹介されるレストランの番号を出力せよ。

# 入力例 1
# 6
# khabarovsk 20
# moscow 10
# kazan 50
# kazan 35
# moscow 60
# khabarovsk 40

# 出力例 1
# 3
# 4
# 6
# 1
# 5
# 2

# 3種類の市名は辞書順で kazan < khabarovsk < moscow です。 
# それぞれの市について、点数が高いレストランから順に紹介されていきます。
# よって、レストランは 3,4,6,1,5,2の順に紹介されていきます。

# 入力例 2
# 10
# yakutsk 10
# yakutsk 20
# yakutsk 30
# yakutsk 40
# yakutsk 50
# yakutsk 60
# yakutsk 70
# yakutsk 80
# yakutsk 90
# yakutsk 100

# 出力例 2
# 10
# 9
# 8
# 7
# 6
# 5
# 4
# 3
# 2
# 1


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # A, P = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    tmps1 = list()
    tmps2 = list()
    for i in range(1, N+1):
        s, p = lines[i].split()
        # 整形
        tmp = (s+(' ')*10)[:11] + str(200-int(p))
        tmps1.append(tmp)
        tmps2.append(tmp)
    tmps1.sort()

    results = list()
    for tmp1 in tmps1:
        for i in range(N):
            if tmps2[i] == tmp1:
                results.append(i+1)

    return results


# 引数を取得
def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40']
        lines_export = [3, 4, 6, 1, 5, 2]
    if pattern == 2:
        lines_input = ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100']
        lines_export = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()
