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):
N = int(input())
cities = {}
citylist = []
for i in range(1,N+1):
    s,p = map(str,input().split())
    if s in cities:
        cities[s].append([int(p),i])
    else:
        cities[s] = [[int(p),i]]
        citylist.append(s)

citylist.sort()
for city in citylist:
    cities[city].sort(reverse = True)
    for j in range(len(cities[city])):
        print(cities[city][j][1])

Solution (Python):
n = int(input())
res_list = []
for i in range(n):
    a,b=input().split()
    res_list.append((a,int(b)))
psorted_res_list = sorted(res_list, key=lambda x: x[1], reverse=True)
sorted_res_list = sorted(psorted_res_list, key=lambda x: x[0])
for i in range(n):
    print(res_list.index(sorted_res_list[i]) + 1)

Solution (Python):
N = int(input())
A = []
for i in range(N):
    S, P = map(str, input().split())
    P = int(P)
    A.append([S, -P])
S = sorted(A)
for j in S:
    print(A.index(j) + 1)

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

a=[]
b=[]
for i in range(n):
  s,p=list(input().split())
  a.append([s,int(p)])
  b.append([s,int(p)])
  
a.sort(key=lambda x:x[1],reverse=True)
a.sort(key=lambda x:x[0])

for i in a:
  print(b.index(i)+1)

Solution (Python):
N = int(input())
A = []
for i in range(N):
    S, P = map(str, input().split())
    P = int(P)
    A.append([S, -P])
S = sorted(A)
for j in S:
    print(A.index(j) + 1)

Solution (Python):
n = int(input())
s = []
r = []
sr = []
for i in range(n):
    s, r = map(str, input().split())
    sr.append([i+1, s, int(r)])

sr1 = sorted(sr, key=lambda x:x[2], reverse=True)

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

for i in range(n):
    print(ans[i][0])

Solution (Python):

N = int(input())

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


ans = sorted(iSP, key = lambda x:x[2], reverse = True)

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

for j,k,l in ans:
    print(j)

Solution (Python):

N = int(input())
S = []
P = []
for _ in range(N):
    s,p = input().split()
    S.append(s)
    P.append(int(p)*(-1))

book = list(zip(S,P))
book_sort = sorted(book)
ans = [book.index(i)+1 for i in book_sort]
for j in ans:
    print(j)

Solution (Python):

N = int(input())
S = []
P = []
for _ in range(N):
    s,p = input().split()
    S.append(s)
    P.append(int(p)*(-1))

book = list(zip(S,P))
book_sort = sorted(book)
ans = [book.index(i)+1 for i in book_sort]
for j in ans:
    print(j)

Solution (Python):
print('\n'.join(map(str, (x[2]+1 for x in sorted((s, -int(p), i) for i, (s, p) in enumerate(zip(*[iter(open(0).read().split()[1:])]*2)))))))

Solution (Python):
N, *A = open(0).read().split()
A = sorted((s, -int(p), i) for i, (s, p) in enumerate(zip(*[iter(A)]*2)))
print('\n'.join(map(str, (x[2]+1 for x in A))))

Solution (Python):
N=int(input())
S=[[] for i in range(N)]
for i in range(N):
    s,p=map(str,input().split())
    S[i]=[s,int(p)*(-1),i]

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

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

Solution (Python):
n=int(input())
s=[]
p=[]
for i in range(n):
    si,pi=input().split()
    s.append(si)
    p.append(int(pi))
ans=[0]*n
for i in range(n-1):
    for j in range(i+1,n):
        if s[i]>s[j]:
            ans[i]+=1
        elif s[i]<s[j]:
            ans[j]+=1
        else:
            if p[i]<p[j]:
                ans[i]+=1
            else:
                ans[j]+=1
z=[0]*n
for i in range(n):
    z[ans[i]]=(i+1)
for i in range(n):
    print(z[i])

Solution (Python):




def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    data = {}

    for i in range(n):
        row = [x for x in input().rstrip().split(" ")]
        s = row[0]
        p = int(row[1])

        if s not in data.keys():
            data[s] = {}

        data[s][p] = i+1

    for city, res in sorted(data.items()):
        for point, num in sorted(res.items(), reverse=True):
            print(num)





if __name__ == "__main__":
    resolve()

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    temps,tempp=input().split()
    temp=[temps,int(tempp),i+1]
    l.append(temp)

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

Solution (Python):
n = int(input())
l = []
for i in range(1,n+1):
    s,p = input().split()
    t = [s,int(p),i]
    l.append(t)
l.sort()
def check(m,i):
    z = list(l[m:i])
    z.sort(key = lambda x: x[1] , reverse = True)
    for j in range(i-m):
        print(z[j][2])
m = 0
for i in range(1,n):
    if l[m][0] != l[i][0]:
        check(m,i)
        m = i
check(m,n)

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

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

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

Solution (Python):
n = int(input())
sp ={}
l = [] 
for i in range(n):
    s,p = input().split()
    sp ={}
    sp["index"] = i+1
    sp["name"] = s
    sp["score"] = int(p)
    l.append(sp)


for dic in sorted(l, key=lambda x: (x["name"], -x["score"])):
    print(dic["index"])

Solution (Python):
n = int(input())
guide = [[i+1, list(int(x) if x.isdigit() else x for x in input().split())] for i in range(n)]
guide = sorted(guide, key = lambda x:(x[1][0],-x[1][1]))

for i in range(n):
    print(guide[i][0])

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

anspoint=sorted(ans,key=lambda x:x[1], reverse=True)
anscity=sorted(anspoint,key=lambda x:x[0])

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

Solution (Python):
N=int(input())
SP=[]
for i in range(N):
    SP.append(list(input().split()))
for i in range(N):
    SP[i].append(i+1)
A=[]
B=[]
C=[]
for i in range(N):
    A.append(SP[i][0])
A.sort()
B.append(A[0])
for i in range(0,N-1):
    if A[i]!=A[i+1]:
        B.append(A[i+1])
for i in range(len(B)):
    C.append([])
for i in range(len(B)):
    for j in range(len(SP)):
        if B[i]==SP[j][0]:
            C[i].append([int(SP[j][1]),SP[j][2]])
for i in range(len(C)):
    for j in range(1,len(C[i])):
        d=C[i][j]
        k=j-1
        while (k>=0 and C[i][k]<d):
            C[i][k+1]=C[i][k]
            k-=1
        C[i][k+1]=d
for i in range(len(C)):
    for j in range(len(C[i])):
        print(C[i][j][1])

Solution (Python):
N = int(input())
M = {}
S = set()
for i in range(N):
	s, p = input().split()
	if s in M:
		t = M[s]
		t.append((int(p), i + 1))
	else:
		t = []
		t.append((int(p), i + 1))
		M[s] = t		
	S.add(s)

for s in sorted(S):
	for t2 in (sorted(M[s], reverse = True)):
		print(t2[1])

Solution (Python):
n = int(input())
chk = []
for i in range(n):
    s, p = map(str, input().split())
    p = int(p)
    chk.append([s, -p])
s = sorted(chk)


for i in s:
    print(chk.index(i)+1)

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

R = []

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

R.sort()

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

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

S=[]
for i in range(n):
    c,p = map(str,input().split())
    S.append( [c,int(p)] )

C=[0]*n
for i in range(n):
    for j in range(n):
        if S[i][0]>S[j][0]:
            C[i]+=1
        elif S[i][0]==S[j][0]:
            if S[i][1]<S[j][1]:
                C[i]+=1

A=[0]*n
for i in range(n):
    print( C.index(i)+1 )

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

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

sp = []

for i in range(n):
    si, pi = list(input().split())
    sp.append([si, -int(pi), i+1])

sp.sort()

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

Solution (Python):
from operator import itemgetter
N = int(input())
R = [list(input().split()) for i in range(N)]
R = [(R[i][0], int(R[i][1]), i+1) for i in range(N)]
S = sorted(R, key=itemgetter(1), reverse=True)
T = sorted(S, key=itemgetter(0))
for t in T:
    print(t[2])

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

D = {}
q = set()
for i in range(N):
    s,p = input().split()
    if s in q:
        D[s].append([int(p),i])
    else:
        D[s] = [[int(p),i]]
        q.add(s)

ans = []
for i in sorted(list(q)):
    D[i].sort(reverse=True)
    for j in D[i]:
        ans.append(j[1])

[print(i+1) for i in ans]

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

m = {}
for i in range(n):
  s, p = input().split()
  p = int(p)
  if s not in m:
    m[s] = []
  
  m[s].append((p, i+1))

shops = sorted(m.items(), key=lambda x : x[0])

for x in shops:
  city, scores = x[0], sorted(x[1], reverse=True, key=lambda x : x[0])
  for score in scores:
    print(score[1])

Solution (Python):
def main():
    n = int(input())
    sp_lst = [0] * n
    for i in range(n):
        sp_lst[i] = list(map(str, input().split()))

    turn_lst = []
    city_lst = []
    for i in range(n):
        city_lst.append(sp_lst[i][0])
    city_lst = list(set(city_lst))
    city_lst.sort()

    number_of_cities = len(city_lst)
    for i in range(number_of_cities):
        city = city_lst[i]
        score_lst = []
        for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

        score_lst = sorted(score_lst)
        score_lst.reverse()
        number_of_score = len(score_lst)
        for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

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

if __name__ == "__main__":
    main()

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

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

res = []
for i in range(n):
  city, value = input().split()
  value = int(value)
  res.append([city, value, i+1])
res_s = sorted(res, key = lambda x: (x[0], -x[1]))
for i in range(n):
  print(res_s[i][2])

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

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

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

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

Solution (Python):
N = int(input())
S_list = []
P_list = []
c = []

for i in range(N):
    S, P = input().split()
    S_list.append(S)
    P_list.append(int(P))

m = S_list
m = list(set(m))
m = sorted(m)

n = 0
a = []
b = []
for i in m:
    for j in range(N):
        if i == S_list[j]:
            a.append(j)
    n = len(a)
    if n != 1:
        for o in range(n):
            b.append(P_list[a[o]])
        b = sorted(b, reverse = True)
        for k in b:
            for l in range(N):
                if k == P_list[l]:
                    c.append(l)
    else:
        c.append(a[0])


    a = []
    b = []

for i in c:
    print(str(i + 1))

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

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

Solution (Python):
def nig (x,y):
    if x[0] == y[0]: return -1 if x[1]>y[1] else 1
    return -1 if x[0] < y[0] else 1
cuc_fuk = []
for x in range(input()):
    a,b = raw_input().split()
    cuc_fuk.append((a,int(b),x+1))
for piss in sorted(cuc_fuk, cmp = nig ):
    print piss[2]

Solution (Python):
def resolve():
    n=int(input())
    d=[]
    for i in range(n):
        s,p=input().split()
        d.append([s,100-int(p),i])
    d.sort()
    ans=[0]*n
    for i in range(n):
        ans[i]=d[i][2]
    for m in ans:
        print(m+1)
resolve()

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

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

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

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
    S,P = map(str,input().split())
    if S not in dic:
        dic[S] = [(-1*int(P), i+1)]
    else:
        dic[S].append((-1*int(P), i+1))
ls = list(dic.items())
ls.sort()
for city in ls:
    points = sorted(city[1])
    for point in points:
        print(point[1])

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

Solution (Python):
N = int(input())
city = {}
for i in range(N):
    s,p = map(str,input().split())
    if s not in city:
        city[s] = [[int(p),i+1]]
    else:
        city[s].append([int(p),i+1])
        city[s].sort(reverse=True)

city = sorted(city.items())

for i in city:
    for j in i[1:]:
        for k in j:
            print(k[1])

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

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

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

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

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

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):
SP_list = []
N = int(input())

for i in range(N):
    items = input().split(' ')
    SP_list.append([i+1, items[0], int(items[1])])

SP_list.sort(key=lambda i:i[2], reverse=True)
SP_list.sort(key=lambda i:i[1])

for i in SP_list:
    print(i[0])

Solution (Python):
n = int(input())
l = []
for i in range(n):
    x, y = input().split()
    l.append([i+1, x, -int(y)])
l = sorted(l, key=lambda x:(x[1],x[2]))

for i in l:
    print(i[0])

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

shop_list_sorted = sorted(shop_list,key=lambda x:(x[0],-x[1]))
for k in range(n):
    print(shop_list_sorted[k][2])

Solution (Python):
n=int(input())
city={}

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

    if c in city:
        city[c].append((i,p))
    else:
        city[c]=[(i,p)]

clst=sorted(list(city.keys()))

for c in clst:
    plst=sorted(city[c],key=lambda x:x[1],reverse=True)

    for i,_ in plst:
        print(i)

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

shop_list_sorted = sorted(shop_list,key=lambda x:(x[0],-x[1]))
for k in range(n):
    print(shop_list_sorted[k][2])

Solution (Python):
N = int(input())
rank = []
for i in range(N):
  name, point = input().split(" ")
  rank.append({
    "name": name,
    "point": 100 - int(point),
    "id": i + 1
  })

rank.sort(key = lambda x: (x["name"], x["point"]))
print("\n".join(list(map(lambda r: str(r["id"]), rank))))

Solution (Python):



class Book:
    """
    =======================
    Book: レストランを紹介する本のクラス。
    =======================
    """
    
    def __init__(self, no, name, value):
        
        self.no = no
        
        self.name = name
        
        self.value = value
	
    def usage(self):
        print(self.__doc__)


book = []
n = int(input())
for i in range(n):
    
    s, p = input().split()
    book.append(Book(i, s, int(p)))


book = sorted(book, key=lambda b: b.value, reverse=True)

book = sorted(book, key=lambda b: b.name)
for b in book:
    
    print(b.no+1)

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

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

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

for s in SP:
    print(s[2])

Solution (Python):



class Book:
  	
    def __init__(self, no, name, value):
      	
        self.no = no
        
        self.name = name
        
        self.value = value

book = []
n = int(input())
for i in range(n):
  	
    s, p = input().split()
    book.append(Book(i, s, int(p)))


book = sorted(book, key=lambda b: b.value, reverse=True)

book = sorted(book, key=lambda b: b.name)
for b in book:
  	
    print(b.no+1)

Solution (Python):
class Book:
    def __init__(self, no, name, value):
        self.no = no
        self.name = name
        self.value = value

book = []
n = int(input())
for i in range(n):
    s, p = input().split()
    book.append(Book(i, s, int(p)))

book = sorted(book, key=lambda b: b.value, reverse=True)
book = sorted(book, key=lambda b: b.name)
for b in book:
    print(b.no+1)

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    s=input().split()
    s[1]=int(s[1])
    l.append(s)
l1=sorted(l, key=lambda l:l[1], reverse=True)
l2=sorted(l1, key=lambda l:l[0])
for i in l2:
    print(l.index(i)+1)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

Solution (Python):




N = int(input())
numbers = []
cities = []
points = []

for i in range(N):
    city, point = input().split()
    numbers.append(i+1)
    cities.append(city)
    points.append(int(point))

def switch_order(l, i, j):
    tmp = l[i]
    l[i] = l[j]
    l[j] = tmp

for i in range(N):
    for j in range(i):
        if cities[j] < cities[i]:
            continue
        if cities[j] > cities[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)
        if cities[j] == cities[i] and points[j] < points[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)

for i in range(N):
    print(numbers[i])

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

import collections
d = collections.defaultdict(list)

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

ordered = list(d.keys())
ordered.sort()

for city in ordered:
    mises = d[city]
    mises = sorted(mises, key=lambda x: x[1], reverse=True)
    for mise in mises:
        print(mise[0])

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

Solution (Python):
N = int(input())
SP = [None] * N
for i in range(N):
    SP[i] = input().split() + [i + 1]
    SP[i][1] = int(SP[i][1]) * (-1)

SP.sort(key = lambda x : (x[0], x[1]))
for i in range(N):
    print(SP[i][2])

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

l=[]
for i in range(n):
  a,b=map(str, input().split())
  b=100-int(b)
  if b<10:
    b=str('0')+str(b)
  elif b==100:
    b="999"
  else:
    b=str(b)
  a=a+b
  l.append(a)

l2=sorted(l)

for i in range(n):
  print(l.index(l2[i])+1)

Solution (Python):
n=int(input())
alist = []
for i in range(n):
    a,b=input().split()
    alist.append([a, int(b)])
blist=sorted(alist,key=lambda x:x[1],reverse=True)
blist.sort(key=lambda x:x[0])
for i in range(n):
  print(alist.index(blist[i])+1)

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

citydic = {}
for i in range(n):
    s,p = map(str,input().split())
    if s not in citydic:
        citydic[s] = [[int(p),i+1]]
    else:
        citydic[s].append([int(p),i+1])
        citydic[s].sort(reverse=True)

citydic = sorted(citydic.items())

for k in citydic:
    for v in k[1:]:
        for n in v:
            print(n[1])

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

Solution (Python):
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


n = ni()
res = [list(input().split() + [i + 1]) for i in range(n)]
res = list(map(lambda x: (x[0], int(x[1]), x[2]), res))
res = sorted(res, key=lambda x: x[0])
start = 0
start_res = res[0][0]
sor_res = []
ans = []
for i in range(n):
    if start_res != res[i][0]:
        end = i - 1
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
        start = i
        start_res = res[i][0]
    if i == n - 1:
        end = i
        sor_res += sorted(res[start:end + 1], key=lambda x: x[1], reverse=True)
for r in sor_res:
    print(r[2])

Solution (Python):
N = int(input())
town = {}

for i in range(N):  
    place, score = input().split()
    tmp = [i+1, int(score)]
    if place in town:
        town[place].append(tmp)
    else:
        town[place] = [tmp]

index = list(town.keys())
index.sort()

for _ in index:
    tmp = town[_]
    tmp = sorted(tmp, reverse=True, key=lambda x: x[1])
    for num in tmp:
        print(num[0])

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

Solution (Python):







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

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

a.sort(key=lambda x:x[0])

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

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

Solution (Python):
n = int(input())
xs = [0] * n
for i in range(n):
    s, p = input().split()
    xs[i] = [s, int(p), i + 1]
xs.sort(key=lambda v: (v[0], 100 - v[1]))
print(*map(lambda v: v[2], xs), sep="\n")

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


SP = sorted(SP, key=lambda x: (x[0], -x[1]))
for spi in SP:
    print(spi[2])

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = {}
for i in range(n):
	S,P = map(str,input().split())
	s[i+1] = [S, -int(P)]

note = sorted(s.items(), key=lambda x: x[1][0])
note.append( (10, ["LOL", 10] ) )
memo = note[0][1][0]
a = []
for i in note:
	if memo != i[1][0]:
		memo = i[1][0]
		a = sorted(a, key=lambda x: x[1][1])
		for j in range(len(a)):
			print(a[j][0])
		a = []
		a.append(i)
	else:
		a.append(i)

Solution (Python):



n = int(input())

restaurants = {}
for i in range(1, n + 1):
    info = input().split()
    restaurants[i] = {
        
        'name': info[0],
        'score': int(info[1])
    }


results = sorted(restaurants.items(), key=lambda x: (x[1]['name'], 100 - x[1]['score']))
output = [r[0] for r in results]
print(*output, sep='\n')

Solution (Python):
N=int(input())
S=[""]*N
T=[""]*N
for i in range(N):
  S[i]=list(input().split())
  S[i][1]=-int(S[i][1])
  T[i]=S[i]
S.sort(key=lambda x:(x[0],x[1]))
for i in range(N):
  for j in range(N):
      if(T[j]==S[i]):
        print(j+1)

Solution (Python):
N = int(input())
list1 = []
for i in range(N):
  aa = input().split()
  a = aa[0]
  b = -int(aa[1])
  xxx = [a,b,i]
  list1.append(xxx)
list1.sort()

for i in range(N):
  list1[i].append(i)

for i in range(N):
  for j in list1:
    if j[3] == i:
      print(j[2]+1)

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

sp = []
for i in range(n):
    _s, _p = input().split()
    sp.append((_s, int(_p), i+1))

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

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

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

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

city_points.sort()

for i in city_points:
    print(i[-1])

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

for i in range(n):
    s, p = input().split()
    p = int(p)
    if s not in city_to_points:
        city_to_points[s] = [[p, i + 1]]
    else:
        city_to_points[s].append([p, i + 1])

kyes = list(city_to_points.keys())
kyes.sort()

for i in kyes:
    restrans = city_to_points[i]
    restrans.sort(reverse=True)
    for j in restrans:
        print(j[1])

Solution (Python):
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
guide = []
for i in range(N):
    s,p=LS()
    guide.append([s,100-int(p),i+1])
guide.sort()
for a in guide:
    print(a[2])

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

L = []

for i in range(N):
    s,p = input().split()
    L.append([s, 100-int(p), i+1])
L.sort()
for j in L:
    print(j[2])

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

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

Solution (Python):

n = int(input())
l = set()
cnt = 1
d = {}
o = {}
for i in range(n):
    s,p = input().split()
    p = int(p)
    d[(s, p)] = cnt
    if s in o:
        x = o[s]
        x.append(p)
        o[s] = x

    else:
        o[s] = [p]

    l.add(s)
    cnt = cnt+1

w = list(l)
w.sort()
k = []

for i in w:
    m = o[i]
    m.sort(reverse = True)
    for j in m:
        
        k.append(d[(i,j)])

for h in k:
    print(h)

Solution (Python):
n = int(input())
l = []
for i in range(n):
    x,y = input().split()
    y = int(y)
    l.append([i+1,x,y])

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

for i in range(n):
    print(l[i][0])

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

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

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

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

restaurants.sort()

for x in restaurants:
    print(x[2])

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

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

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

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

Solution (Python):
N = int(input())
sp = [list(input().split()) for i in range(N)]
for i in range(N):
  sp[i].append(i+1)
sorted_data = sorted(sp, key=lambda x:(x[0], -int(x[1])))
for i in range(N):
  print(sorted_data[i][2])

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

Solution (Python):
N = int(input())
SPI = [input().split()+[i] for i in range(N)]
SPI.sort(key=lambda x:(x[0], -int(x[1])))
for _,_,i in SPI:
    print(i+1)

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

spl = {}
spl = []
for i in range(n):
    s,p = map(str, input().split())
    p = int(p)
    spl.append((s,p*(-1),i+1))
    
    

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
ans = []
for i in range(n):
    name,score = input().split()
    score = int(score)
    ans.append([name,score,i+1])
ans = sorted(ans,key = lambda x:x[1],reverse = True)
ans = sorted(ans,key = lambda x:x[0])
for i in range(n):
    print(ans[i][2])

Solution (Python):
n = int(input())
spi = sorted([list(input().split())+[i+1] for i in range(n)])
ans = []
before = ""
for s,p,i in spi:
    if ans == []:
        ans = [[int(p),i]]
        before = s
    else:
        if before == s:
            ans.append([int(p),i])
        else:
            for j in sorted(ans)[::-1]: print(j[1])
            ans = [[int(p),i]]
            before = s
if ans:
    for i in sorted(ans)[::-1]: print(i[1])

Solution (Python):
N = int(input())
A = [list(input().split()) for _ in range(N)]
A = sorted([(A[i][0],int(A[i][1]),i+1) for i in range(N)],key=lambda x:x[1],reverse=True)
A = sorted(A,key=lambda x:x[0])
for i in range(N):
    print(A[i][2])

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


n = ini()
res = []
for i in range(n):
    s, p = ins().split()
    p = int(p)
    res.append((s, -p, i))
res.sort()


def solve():
    return [i + 1 for s, p, i in res]


print(*solve(), sep="\n")