Problem:
 Score : 200 points    Problem Statement You have decided to write a book introducing good restaurants.
There are N restaurants that you want to introduce: Restaurant 1 , Restaurant 2 , ... , Restaurant N . Restaurant i is in city S_i , and your assessment score of that restaurant on a 100 -point scale is P_i .
No two restaurants have the same score.  You want to introduce the restaurants in the following order:   The restaurants are arranged in lexicographical order of the names of their cities.  If there are multiple restaurants in the same city, they are arranged in descending order of score.   Print the identification numbers of the restaurants in the order they are introduced in the book.      Constraints  1 ≤ N ≤ 100  S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.  0 ≤ P_i ≤ 100  P_i is an integer.  P_i ≠ P_j  (1 ≤ i < j ≤ N)         Input Input is given from Standard Input in the following format:  N  S_1  P_1  :  S_N  P_N       Output Print N lines. The i -th line ( 1 ≤ i ≤ N ) should contain the identification number of the restaurant that is introduced i -th in the book.        Sample Input 1 6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40      Sample Output 1 3
4
6
1
5
2  The lexicographical order of the names of the three cities is kazan  <  khabarovsk  <  moscow . For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2 .       Sample Input 2 10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100      Sample Output 2 10
9
8
7
6
5
4
3
2
1

Solution (Python):
from operator import itemgetter

n = input()
n = int(n)


li = [input().split() for i in range(n)]
for i in range(n):
  li[i].append(i+1)
  li[i][1] = int(li[i][1])
li.sort(key=lambda x:(x[0], -x[1]))
for i in range(n):
  print(li[i][2])

Solution (Python):
n = int(input())
*a, = [input().split() for i in range(n)]

for i in range(n):
    a[i].append(i+1)

a_point = sorted(a, key = lambda x: int(x[1]), reverse = True)

a_name = sorted(a_point, key = lambda x: x[0])

ans = []

for i in a_name:
    print(i[2])

Solution (Python):
N = int(input())
review = []
for i in range(N):
    name, score = input().split()
    score = int(score)
    review.append([name, -score, i+1])

review.sort()
for res in review:
    print(res[2])

Solution (Python):


L = []

N = int(input())

for i in range(N):
    x,y=[str(i) for i in input().split()]
    y = int(y)
    L.append([x,-y,i+1])

L.sort()

for i in range(N):
    print(L[i][2])

Solution (Python):

import bisect
from collections import defaultdict

def main():
    N = int(input())
    city_score_list = []
    for i in range(N):
        s, p = input().split()
        city_score_list.append((i, s, int(p)))

    city_score_list = sorted(city_score_list, key=lambda x: (x[1], -x[2]))
    for i, s, p in city_score_list:
        print(i+1)

if __name__ == '__main__':
    main()

Solution (Python):
from functools import cmp_to_key

def cmp(a, b):
    if a[0] == b[0]:
        return -1 if a[1] > b[1] else 1
    else:
        return -1 if a[0] < b[0] else 1


def main():
    N = int(input())
    SP = []
    for i in range(N):
        sp = input().split()
        SP.append((sp[0], int(sp[1]), i+1))
    for a in sorted(SP, key=cmp_to_key(cmp)):
        print(a[2])


main()

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2



def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)



def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    ans = []
    for i in range(N):
        S, P = input().split()
        ans.append((S, -int(P), i + 1))

    ans.sort()
    for t in ans:
        print(t[2])


if __name__ == '__main__':
    main()

Solution (Python):
from operator import itemgetter

N = int(input())
ranking = []
for i in range(N):
  si, pi = input().split()
  ranking.append((si,int(pi)*(-1),i+1))

sorted_ranking = sorted(ranking, key = lambda x: (x[0],x[1]))
for i in range(N):
  print(sorted_ranking[i][2])

Solution (Python):

N = int(input())
lis = []

for i in range(N):

    S , P = input().split()

    P = int(P)

    lis.append([S,-P,i+1])

lis.sort()

for i in lis:

    print (i[2])

Solution (Python):


n=list(map(int, input().split()))[0]
lst=[]
name_lst=[]
for i in range(n):
    name,score=input().split()
    if name not in name_lst:
        name_lst.append(name)
    lst.append({"number":i,"name":name,"score":int(score)})

answer=[]
for n in sorted(name_lst):
    l1=[i for i in lst if i["name"]==n]
    l1=sorted(l1,key=lambda x:x["score"])
    answer.extend(reversed(l1))

a=[print(i["number"]+1) for i in answer]

Solution (Python):
N = int(input())
lst = []

for i in range(N):
    c,p = input().split()
    lst.append((c,int(p)*-1,i+1))
a = sorted(lst)
for i in range(N):
    print(a[i][2])

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
tupleList=[]
for i in range (N):
  city,score = stdin.readline().rstrip().split()
  tupleList.append((city,int(score)*-1))
tupleListSort=sorted(tupleList)

for i in range (N):
  print(tupleList.index(tupleListSort[i])+1)

Solution (Python):
n = int(input())
sp = [0] * n
for i in range(n):
    tmp = list(input().split())
    tmp[1] = 100 - int(tmp[1])
    tmp.append(i+1)
    sp[i] = tmp
sp.sort()
for x in sp:
    print(x[2])

Solution (Python):
n = int(input())
lst = []
for i in range(n):
    lst.append(input().split())

for i in lst:
    i[-1] = int(i[-1])

s = sorted(lst, key=lambda x:(x[0], -x[1]))
ans = []

for i in s:
    for ind, j in enumerate(lst):
        if i == j:
            ans.append(ind+1)
        else:
            continue

for i in ans:
    print(i)

Solution (Python):
from operator import itemgetter

N = int(input())
ranking = []
for i in range(N):
  si, pi = input().split()
  ranking.append((si,int(pi)*(-1),i+1))

sorted_ranking = sorted(ranking, key = lambda x: (x[0],x[1]))
for i in range(N):
  print(sorted_ranking[i][2])

Solution (Python):
n = int(input())
spdict = []
for i in range(n):
    s, p = list(input().split())
    spdict.append([s, 101 - int(p), i + 1])
spdict = sorted(spdict)
for i in range(n):
    print(spdict[i][2])

Solution (Python):
list_SP = []
N = int(input())

for i in range(N):
  S, P = input().split()
  list_SP.append([S, 100 - int(P), i+1])
  
  
sorted_listSP = sorted(list_SP)
for data in sorted_listSP:
  print(data[2])

Solution (Python):
[print(i[2]+1) for i in sorted(sorted([[int(j) if j.isdecimal() else j for j in input().split()]+[i] for i in range(int(input()))], key=lambda x:x[1], reverse=True), key=lambda x:x[0])]

Solution (Python):
def solve(string):
    n, *sp = string.split()
    sp = sorted([(s, -int(p), i) for i, (s, p) in enumerate(zip(*[iter(sp)] * 2), start=1)])
    return "\n".join([str(i) for *_, i in sp])


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))

Solution (Python):
n=int(input())
data=[[i for i in input().split()]+[_] for _ in range(n)]
for i in range(n):
    data[i][1]=int(data[i][1])
data=sorted(sorted(data,key=lambda x:x[1])[::-1],key=lambda x:x[0])
print(*[k+1 for i,j,k in data],sep="\n")

Solution (Python):
from operator import itemgetter
n = int(input())
ranking = []
for i in range(n):
    si, pi = input().split()
    ranking.append([si,int(pi),i])
ranking = sorted(ranking, key = itemgetter(1))[::-1]
ranking = sorted(ranking, key = itemgetter(0))
for item in ranking:
    print(item[2]+1)

Solution (Python):
from operator import itemgetter

number = int(input())

listInput = [input() for i in range(number)]

record = []

for i in range(len(listInput)):
	tumple = listInput[i].split()
	record.append((tumple[0], int(tumple[1]), i + 1))

sort1 = sorted(record, key = itemgetter(1), reverse = True)
sort2 = sorted(sort1, key = itemgetter(0))

for a,b,c in sort2:
	print(c)

Solution (Python):
n = int(input())

guide_book_list = []

for i in range (n) :
    a_list = list((input().split()))+[i+1]
    guide_book_list.append(a_list)
    guide_book_list[0+i][1]=int(guide_book_list[0+i][1])
    guide_book_list[0 + i][1] = -(guide_book_list[0 + i][1])

guide_book_list.sort()

for j in range (n) :
    print(guide_book_list[0+j][2])

Solution (Python):
from operator import itemgetter
n = int(input())
sps = []
for idx in range(n):
    s, p = input().split()
    sps.append((s, -1 * int(p), idx + 1))

sps.sort(key=itemgetter(0, 1))
for _, _, num in sps:
    print(num)

Solution (Python):


from operator import itemgetter
a = int(input())
book = []
for i in range(a):
    array = input().split()
    book.append((array[0], int(array[1]) * -1, i))

ans = sorted(book, key=itemgetter(0, 1))

for i in range(a):
    print(ans[i][2] + 1)

Solution (Python):
N = int(input())
SP = []

for i in range(N):
  s,p = input().split()
  SP.append([i+1,s,int(p)])

SP.sort(reverse = True, key = lambda x: x[2])
SP.sort(key = lambda x: x[1])

for num,_,_ in SP:
  print(num)

Solution (Python):
N = int(input())

a = []
for i in range(1, N + 1):
    s, p = input().split()
    a.append((s, int(p), i))
a.sort(key=lambda x: (x[0], -x[1]))


for _, _, i in a:
    print(i)

Solution (Python):
n = int(input())
a = [list(input().split()) + [i + 1] for i in range(n)]
sorted_a=sorted(a,key=lambda x: (x[0], -int(x[1])))
for ans in sorted_a:
    print(ans[2])

Solution (Python):
number=int(input())
book=[]
for n in range(number):
    book.append(input().split())

for i in range(len(book)):
    book[i].append(i+1)
    book[i][1]=int(book[i][1])

book1=sorted(book,key=lambda k:-k[1])
book2=sorted(book1,key=lambda k:k[0])

for i in range(len(book2)):
    print(book2[i][2])

Solution (Python):
N = int(input())

names = []
points = []
ans = []

for i in range(N):
    name, point = str(input()).split(" ")
    point = int(point)
    ans.append(1)
    names.append(name)
    points.append(int(point))
    if i == 0:
        continue
    if i == 1:
        if name < names[0]:
            ans[0] += 1
        elif name == names[0] and point > points[0]:
            ans[0] += 1
        else:
            ans[1] += 1
        continue
    for j in range(len(ans) - 1):
        if name < names[j]:
            ans[j] += 1
        elif name == names[j] and point > points[j]:
            ans[j] += 1
        else:
            ans[i] += 1

for i in range(N):
    print(ans.index(min(ans)) + 1)
    ans[ans.index(min(ans))] = 101

Solution (Python):
n = int(input())
li = [list(input().split())+[i+1] for i in range(n)]

ansli = sorted(li, key=lambda x: int(x[1]), reverse=True)
ans_li = sorted(ansli, key=lambda x: x[0])


for i in ans_li:
  print(int(i[2]))

Solution (Python):
def abc():
    n = int(input().rstrip())
    stores = []
    for i in range(1, n + 1):
        name, score = input().rstrip().split()
        stores.append((i, name, int(score)))
    stores.sort(key=lambda x:(x[1], -x[2]))
    for x in stores:
        print(x[0])


abc()

Solution (Python):
def main(n):
	lst= []
	for i in range(1,n+1):
		c, v = input().split()
		lst += [[c, -int(v), i]]
	lst.sort(key=lambda x:(x[0], x[1]))
	for i in lst:
		print(i[2])
	return

main(int(input()))

Solution (Python):
N = int(input())
SP = []
for i in range(N):
    s, p = [s for s in input().split()]
    p = int(p)
    SP.append((s, p, i + 1))

SP.sort(key=lambda x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])
for sp in SP:
    print(sp[2])

Solution (Python):
n=int(input())
list=[]
for i in range(n):
    s,p=input().split()
    p=int(p)
    list.append([s,-p,i+1])
list.sort()
for i in range(n):
    print(list[i][2])

Solution (Python):
n = int(input())
b = {}
cities = []
for i in range(n):
    c, r = tuple([i for i in input().split(' ')])
    cities.append(c)
    if c in b:
        b[c].append((i + 1, int(r)))
    else:
        b[c] = [(i + 1, int(r))]

cities = list(set(cities))
cities.sort()
for c in cities:
    l = b[c]
    for i in sorted(l, key=lambda x: x[1], reverse=True):
        print(i[0])

Solution (Python):
n = int(input())
book = []
for _ in range(n):
    s,p = input().split()
    book.append((s.strip(), int(p)))

rank = sorted(book, key=lambda x: (x[0], -x[1]))
for i in rank:
    print(int(book.index(i)) + 1)

Solution (Python):
N = int(input())

SP = []
for i in range(N):
    s, p = input().split()
    SP.append((i + 1, s, int(p)))

SP.sort(key=lambda sp: (sp[1], -sp[2]))

for sp in [sp[0] for sp in SP]:
    print(sp)

Solution (Python):
n = int(input())

list = []

for i in range(n):
	city,score = input().split()
	list.append({'id': i + 1, 'city': city, 'score': int(score)})

list = sorted(list, key=lambda x:x['score'], reverse=True)
list = sorted(list, key=lambda x:x['city'])

for dict in list:
	print(dict['id'])

Solution (Python):
n=int(input())
sp=[]
for i in range(n):
    s,p=input().split()
    sp.append([s,int(p),i+1])
sp.sort(key=lambda sp:(sp[0],-sp[1]))
for i in sp:print(i[2])

Solution (Python):
number=int(input())
book=[]
for i in range(0,number):
  book.append(input().split())
for i in range(0,len(book)):
    book[i][1]=int(book[i][1])
    book[i].append(i+1)
book1=sorted(book,key=lambda x: -x[1])
book2=sorted(book1,key=lambda x: x[0])
for i in range(0,len(book2)):
  print(book2[i][2])

Solution (Python):
N = int(input())
SP = []
for i in range(1, N+1):
    Si, Pi = map(str, input().split())
    SP.append([Si, int(Pi), i])

SP = sorted(SP, key=lambda x: x[1], reverse=True)
SP = sorted(SP, key=lambda x: x[0])
for sp in SP:
    print(sp[2])

Solution (Python):
n = int(input())
a = [list(input().split()) + [i + 1] for i in range(n)]
for i in range(n):
	a[i][1] = -(int(a[i][1]))
a.sort()
for i in range(n):
	print(a[i][2])

Solution (Python):
n = int(input())
sp = [[0]*3 for j in range(n)]
a = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    a.append([s, -p, i+1])

a.sort()
for s, p, i in a:
    print(i)

Solution (Python):
N = int(input())
_input = []
for i in range(N):
    _input.append([i+1] + list(map(str,input().split())))

_input.sort(key=lambda x:(x[1],-int(x[2])))

for i in range(N):
    print(_input[i][0])

Solution (Python):
n=int(input())

mydict=[[0 for _ in range(3)]for _ in range(n)]

for	x in range(1,n+1):
	a,b=input().split()

	mydict[x-1][0]=a
	mydict[x-1][1]=-int(b)
	mydict[x-1][2]=x

mydict.sort(key=lambda x:(x[0],x[1]))



for x in range(n):
	print(mydict[x][2])

Solution (Python):
import sys

input = sys.stdin.readline
n = int(input())
r_list = []
for i in range(1, n+1):
    r = input().split()
    city, point = r[0], int(r[1])
    r_list.append([city, -point, i])
r_list.sort()
for r in r_list:
    print(r[2])

Solution (Python):
N = int(input())

ans = list()
for i in range(N):
    s, p = input().split()
    p = int(p)
    ans.append((i+1, s, p))

ans = sorted(ans, key=lambda x: (x[1], -x[2]))

for a in ans:
    print(a[0])

Solution (Python):
N = int(input())

arr = []
for i in range(N):
  s, p = input().split()
  p = int(p)
  arr.append((s, -p, i+1))

arr.sort()
for s, p, i in arr:
  print(i)

Solution (Python):
from operator import itemgetter

def main():

    N = int(input())
    if 0 > N or N > 100:
        print("input N error")
        exit()
        
    answer = []
    for i in range(N):
        s, p = input().split()
        answer.append([s, -int(p), i+1])

    answer.sort(key=itemgetter(0,1))
    for i in range(len(answer)):
        print(answer[i][2])
        
        
if __name__ == '__main__':

    main()

Solution (Python):
def main():

    N = int(input())
    if 0 > N or N > 100:
        print("input N error")
        exit()
        
    answer = []
    for i in range(N):
        s, p = input().split()
        answer.append([s, -int(p), i+1])

    answer.sort()
    for i in range(len(answer)):
        print(answer[i][2])
        
        
if __name__ == '__main__':

    main()

Solution (Python):


n=int(input())

a=[]

for i in range(n):
    s,p=input().split()
    p = int(p)
    a.append((s, -p, i+1))

a.sort()
for k in a:
    print(k[2])

Solution (Python):
n = int(input())
li = []
for i in range(1, n+1):
    name, point = input().split()
    point = int(point)
    li.append([name, -point, i])

li.sort()


for ans in li:
    print(ans[2])
    continue

Solution (Python):
*D, = open(0)

n = int(D[0])
data = []
for i in range(n):
    city, score = D[i+1].split()
    data.append([i+1, city, int(score)])

data.sort(key=lambda x:x[2], reverse=True)
data.sort(key=lambda x:x[1])
for it in data:
    print(it[0])

Solution (Python):
n = int(input())
li = []
for i in range(n):
    s, p = input().split()
    li.append((s, -int(p), i+1))

li.sort()
for _, _, id in li:
    print(id)

Solution (Python):
n = int(input())
li = []
for i in range(n):
    s, p = input().split()
    li.append((s, -int(p), i+1))

li.sort()
for _, _, id in li:
    print(id)

Solution (Python):
n = int(input())
restaurants = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    restaurants.append((i, s, p))



restaurants.sort(key=lambda x: (x[1], -x[2]))
for res in restaurants:
    print(res[0] + 1)

Solution (Python):
from sys import exit

N = int(input())

R = []

for i in range(1, N + 1):
    s, p = input().split()

    x = (s, int(p))
    R.append((x, i))

R = sorted(R, key=lambda x: -x[0][1])
R = sorted(R, key=lambda x: x[0][0])

for r in R:
    print(r[1])

Solution (Python):
n = int(input())
li = []
for i in range(n):
    s, p = input().split()
    t = (s, -int(p))
    li.append((t, i+1))

for item in sorted(li):
    print(item[1])

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s, p = input().split()
    if d.get(s) == None:
        d[s] = [[int(p), i]]
    else:
        d.get(s).append([int(p), i])
for key in sorted(d.keys()):
    for v, i in sorted(d.get(key), key=lambda x: x[0], reverse=True):
        print(i+1)

Solution (Python):





N = int(input())

rest_list = []

for i in range(N):
  city, score = input().split()
  rest_list.append([city, int(score), (i+1)])


ans_list = sorted(rest_list, key = lambda x: (x[0], -x[1]))

for i in range(N):
  print(ans_list[i][2])

Solution (Python):
N = int(input())
lst = []
for i in range(N):
  s, p = input().split()
  lst.append([s, p, i])
  lst_2 = sorted(lst, key = lambda x : (x[0], -1 * int(x[1])))
  
for i in lst_2:
  print(i[2] + 1)

Solution (Python):


"""
Created on Sun Jun  9 13:46:43 2019

@author: YudNK
"""
n = int(input())
rest = [(input().split()) for i in range(n)]
for i in range(n):
    rest[i].append(i)
rest.sort(key= lambda x:(x[0],-1*int(x[1])))
for i in rest:
    print(i[2]+1)

Solution (Python):
n = int(input())
sp = []
for i in range(1,n+1):
    s,p = input().split()
    p = int(p)
    sp.append((s,p,i))
items = sorted( sp, key = lambda x:x[1],reverse = True)
items = sorted( items, key = lambda x:x[0])

for i in items:
    print(i[2])

Solution (Python):
n = int(input())
l = []
for i in range(n):
    s,p = input().split()
    l.append((i+1,int(p),s))
l.sort(key=lambda x : x[1],reverse=True)
l.sort(key=lambda x : x[2])
for i in range(n):
    print(l[i][0])

Solution (Python):


import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
rest = []
for i in range(N):
    c, s = input().split()
    s = -int(s)
    rest.append([c, s, i])

rest = sorted(rest, key=lambda x: [x[0], x[1]])
for r in rest:
    print(r[2]+1)

Solution (Python):
N = int(input())
S = []

for i in range(N):
    s, p = input().split()
    S.append((s, int(p), i + 1))

S.sort(key = lambda x: x[1], reverse = True)
S.sort(key = lambda x: x[0])

for i in range(N):
    print(S[i][2])

Solution (Python):
n = int(input())
list=[]

for i in range(n):
  s, p = input().split()
  list.append((s,int(p),i+1))

list.sort(key=lambda x:x[1],reverse=True)
list.sort(key=lambda x:x[0])

for i in range(n):
  print(list[i][2])

Solution (Python):
N = int(input())
score_list = []
for i in range(1, N+1):
  town, score_i = map(str, input().split())
  list_i = [i]
  list_i.append(town)
  list_i.append(-int(score_i))

  score_list.append(list_i)

score_list = sorted(score_list, key=lambda x: (x[1],x[2]))

for score in score_list:
  print(score[0])

Solution (Python):
N = int(input())
rest = []
for i in range(N):
  S,P = input().split()
  inrest = [ i + 1 , str(S) , int(P)]
  rest.append(inrest)

rest = sorted(rest , key = lambda x:x[2] , reverse = True)
rest = sorted(rest , key = lambda x:x[1])

for i in range(N):
  print(rest[i][0])

Solution (Python):
n = int(input())
li = []
for i in range(n):
    li.append(list(input().split()))
    li[i].append(i + 1)
    li[i][1] = int(li[i][1])
li.sort(key=lambda x: x[1], reverse = True)
li.sort(key=lambda x: x[0])
for i in li:
    print(i[2])

Solution (Python):
N = int(input())

ls = []
for i in range(N):
    S, P = input().split()
    ls.append((i, S, int(P)))

ls.sort(key=lambda x: x[2], reverse=True)
ls.sort(key=lambda x: x[1])

for l in ls:
    print(l[0] + 1)

Solution (Python):
n=int(input())
data_origin=[input().split() for i in range(n)]
for i in range(n):
  data_origin[i][1] = int(data_origin[i][1])
data = sorted(data_origin, key=lambda x:x[1],reverse=True)
data = sorted(data, key=lambda x:x[0])
for i in data:
  print(1+data_origin.index(i))

Solution (Python):
def solve():
    n = int(input())
    d_org = {}
    d = {}
    for i in range(n):
        s, p = input().split()
        p = int(p)
        if s not in d:
            d_org[s] = {p: i + 1}
            d[s] = [p]
        else:
            d_org[s][p] = i + 1
            d[s].append(p)

    
    

    for s in sorted(d.keys()):
        for p in sorted(d[s], reverse=True):
            
            print(d_org[s][p])


if __name__ == '__main__':
    solve()

Solution (Python):


n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    a.append([s, -p, i + 1])

a.sort()

for i in a:
    print(i[2])

Solution (Python):
N = int(input())
restaurants = []

for i in range(N):
    idx = i + 1
    S, P = input().split()
    tuple = ( (idx, str(S), int(P)) )

    restaurants.append(tuple)

restaurants = sorted(restaurants, key=lambda x:x[2], reverse = True)  
restaurants = sorted(restaurants, key=lambda x:x[1])

for i in range(N):
    print (restaurants[i][0])

Solution (Python):
N = int(input())
s = []
for i in range(N):
    tmp = input().split()
    tmp .append(i+1)
    tmp[1] = int(tmp[1])
    s.append(tmp)

s.sort(key=lambda x: x[1], reverse=True)
s.sort(key=lambda x: x[0])
for x in s:
    print(x[2])

Solution (Python):
n = int(input())
restaurant_list = []
for i in range(n):
    s, p = input().split()
    restaurant_list.append([s, int(p), i+1])

restaurant_list_ordered = sorted(restaurant_list, key=lambda x: (x[0], -x[1]))

for e in restaurant_list_ordered:
    print(e[2])

Solution (Python):
N = int(input())
data = {}
for i in range(1, N + 1):
  s, p = input().split()
  p = int(p)
  if s in data.keys():
    data[s][p] = i
  else:
    data[s] = {p : i}

for s in sorted(data.keys()):
  for p in reversed(sorted(data[s].keys())):
    print(data[s][p])

Solution (Python):
n = int(input())
di = {}
li = []
for x in range(n):
    input_data = list(input().split())
    if input_data[0] not in di:
        di[input_data[0]] = {int(input_data[1]): x}
        li.append(input_data[0])
    else:
        di[input_data[0]][int(input_data[1])] = x

li.sort()
for res in li:
    point_di = di[res]
    point_di_sorted = sorted(point_di.items(), key=lambda x:-x[0])
    for _,rank in point_di_sorted:
        print(rank + 1)

Solution (Python):
N = int(input())
SP = []
for i in range(1,N+1):
    tmp =[]
    S_tmp,P_tmp = input().split()
    tmp.append(S_tmp)
    tmp.append(int(P_tmp))
    tmp.append(i)
    SP.append(tmp)

SP.sort()

tmp = []
for i in range(N):
    if (len(tmp)==0):
        tmp.append(SP[i])
    elif(tmp[0][0]==SP[i][0]):
        tmp.append(SP[i])
    else:
        tmp.sort(reverse=True,key=lambda x: x[1])
        for j in (tmp):
            print(j[2])
        
        tmp = []
        tmp.append(SP[i])

tmp.sort(reverse=True,key=lambda x: x[1])
for j in (tmp):
            print(j[2])

Solution (Python):


N = int(input())

arr=[]

for i in range(N):
    S, P = input().split()
    arr.append([i+1, S, int(P)])

arr.sort(key=lambda x: x[2], reverse=True)
arr.sort(key=lambda x: x[1])

for i in range(N):
    print(arr[i][0])

Solution (Python):
import collections as cl

N=int(input())

L = []

for i in range(N):
  S,P_ = input().split()
  P = int(P_)
  
  flg = False
  for j in range(len(L)):
    if L[j][0]>S or (L[j][0]==S and L[j][1]<P):
      L.insert(j,(S,P,i))
      flg = True
      break
  if flg==False:
    L.append((S,P,i))
        

for i in range(N):
  print(L[i][2]+1)

Solution (Python):
N = int(input())
rests = []
for i in range(N):
    s, p = input().split()
    rests.append((i+1, s, int(p)))
restsSorted = sorted(rests, key=(lambda x: x[2]), reverse=True)
restsSorted = sorted(restsSorted, key=(lambda x: x[1]))
for x in restsSorted:
    print(x[0])

Solution (Python):
n = int(input())

s = []
d = []
kansei = []





k = 0

for i in range(n):
    e = input().split()
    b = str(e[0])
    c = int(e[1])
    s.append(b)
    d.append(c)
    kansei.append(0)

for i in range(n):
     
     k = 0
     for j in range(n):
        if s[i] > s[j]:
            k += 1
        elif s[i] == s[j]:
            if d[i] < d[j]:
                k += 1
     kansei[k] = i + 1
     

for i in range(n):
    print(kansei[i])

Solution (Python):
N = int(input())
L = []
for i in range(N):
    S,P = input().split()
    L.append([S,-int(P),i+1])
for l in sorted(L):
    print(l[2])

Solution (Python):
N = int(input())
L=[]
for i in range(N):
    tmp = input().split()
    L.append((tmp[0],int(tmp[1]),i+1))
    
L.sort(reverse=True, key=lambda x:x[1])
L.sort(key=lambda x:x[0])

for i in L:
    print(i[2])

Solution (Python):
A = {}

for i in range(int(input().strip())):
  s, p_s = input().strip().split(' ')
  if s not in A: A[s] = []
  A[s].append((int(p_s), i + 1))

for s, ls in sorted(A.items()):
  for p, i in sorted(ls, reverse=True):
    print(i)

Solution (Python):
N = int(input())
List1 = [[]*2]*N
Dict = []*N
Score = []*N
Num = list(range(1,N+1))

for i in range(N):
    List1[i] = list(map(str, input().split()))
    
for i in range(N):
    for j in range(2):
        if j % 2 == 0:
            Dict.append(List1[i][j])
        else:
            Score.append(int(List1[i][j]))

for i in range(N):
    for j in range(N-1-i):
        if Dict[j] > Dict[j+1]:
            Dict[j], Dict[j+1] = Dict[j+1], Dict[j]
            Score[j], Score[j+1] = Score[j+1], Score[j]
            Num[j], Num[j+1] = Num[j+1], Num[j]
        elif Dict[j] == Dict[j+1]:
            if Score[j] < Score[j+1]:
                Dict[j], Dict[j+1] = Dict[j+1], Dict[j]
                Score[j], Score[j+1] = Score[j+1], Score[j]
                Num[j], Num[j+1] = Num[j+1], Num[j]
            else:
                pass
        else:   
            pass
        
for i in range(N):            
    print(Num[i])

Solution (Python):


N = int(input())
di = []
tmp =[]

for i in range(N):
    si, pi = input().split()
    pi = int(pi) * (-1)
    tmp = [si, pi, i]
    di.append(tmp)
di = sorted(di, key=lambda x: (x[0], x[1]))    

for i in range(N):
    print(di[i][2]+1)

Solution (Python):
n = int(input())
lst = [list(input().split())+[i+1] for i in range(n)]


lst = sorted(lst, key= lambda x:(x[0],-int(x[1])))

for i in range(n):
   print(lst[i][2])

Solution (Python):
from sys import stdin

N = int(input())
lst = []
for i in range(N):
    city, score = stdin.readline().split()
    lst.append((city, int(score), i + 1))

lst.sort(key=lambda x: x[1], reverse=True)
lst.sort(key=lambda x: x[0])
for tup in lst:
    c, s, i = tup
    print(i)

Solution (Python):
n = int(input())
lst = [list(input().split())+[i+1] for i in range(n)]



lst = sorted(lst, key= lambda x:(x[0],-int(x[1])))

for i in range(len(lst)):
    print(lst[i][2])

Solution (Python):
import collections
N=int(input())
S=[]
P=[]
ids=[]
for i in range(N):
    s,p=input().split()
    p=int(p)
    S.append(s)
    P.append(p)
    ids.append(i+1)

s_ps = collections.defaultdict(list)
for s,p,i in zip(S,P,ids):
    s_ps[s].append((i,p))

for s, ps in sorted(s_ps.items(),key=lambda x:x[0]):
    for id, p in sorted(ps,key=lambda x:-x[1]):
        print(id)

Solution (Python):
N = int(input())
L = []
for i in range(N):
  a,b = input().split()
  L.append([a,100-int(b),i+1])
L.sort()
for i in range(N):
  print(L[i][2])

Solution (Python):
n = int(input())
lst = [list(input().split())+[i+1] for i in range(n)]



lst = sorted(lst, key=lambda x: (x[0], -int(x[1])))

for i in range(0, len(lst)):
    print(lst[i][2])

Solution (Python):
N = int(input())
l = []

for i in range(N):
    store,rank = map(str, input().split())
    number = i+1
    l.append([store,int(rank),number])

sorted_list = sorted(l, key=lambda x:(x[0],-x[1]))
for i in range(N):
    print(sorted_list[i][2])

Solution (Python):
n = int(input())
lst = [list(input().split())+[i+1] for i in range(n)]

for i in sorted(lst, key = lambda x: (x[0], -int(x[1]))):
    print(i[2])

Solution (Python):
n = int(input())
a = [input().split() for _ in range(n)]
for i in sorted(range(n), key=lambda i: (a[i][0], -int(a[i][1]))):
    print(i + 1)

Solution (Python):
N = int(input())
restaurants = list()
for i in range(1, N+1) :
    S, P = input().split()
    r = {'i' : i, 'S' : S, 'P' : int(P)}
    restaurants.append(r)
restaurants.sort(key=lambda r : (r['S'], -r['P']))
for r in restaurants :
    print(r['i'])

Solution (Python):
N = int(input())
a = []

for i in range(N):
  N, k = input().split()
  k = int(k)
  
  a.append([N, -k, i+1])
a.sort()

for a_ in a:
  print(a_[2])

Solution (Python):
n=int(input())
t=[]
for i in range(n):
    x,y=input().split()
    b=[x,-int(y),i+1]
    t.append(b)
t.sort()
for a in t:
    print(a[2])

Solution (Python):
n = int(input())

res = []
for i in range(n):
    s, s_p = input().split()
    p = int(s_p)
    res.append(((s, -p), i + 1))

res.sort(key=lambda r: r[0])

for r in res:
    print(r[1])

Solution (Python):
N = int(input())

guides = []
for i in range(N):
    S, P = map(str, input().split())
    guides.append([i+1, S, int(P)])

guides.sort(key=lambda x: (x[1], -x[2]))

for i in range(len(guides)):
    print(guides[i][0])

Solution (Python):
N = int(input())
ans = []
for i in range(1, N + 1):
    S, P = input().split()
    ans.append([S, -int(P), i])
ans.sort()

for a in ans:
    print(a[2])

Solution (Python):
n = int(input())
data = [[i+1] + input().split() for i, _ in enumerate(range(n))]
data = [(i, x, int(y)) for i, x, y in data]
for x in sorted(data, key=lambda x: (x[1], -x[2])):
    print(x[0])

Solution (Python):
n = int(input())
restaurants = []
for index in range(1,n+1):
    
    tmp = list(map(lambda x:int(x)+1 if x.isdecimal() else x, input().split()))
    
    tmp.append(index)
    restaurants.append(tmp)

ans = sorted(restaurants, key=lambda x:(x[0],-x[1]))
for i in ans:
    print(i[2])