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):
import copy
N = int(input())
sp = [[] for _ in range(N)]
for i in range(N):
    sp[i] = list(input().split())
    sp[i][1] = int(sp[i][1])
alf = []
for v in sp:
    alf.append(v[0])
set(alf)

alf.sort(reverse=True)
for v in sp:
    for i, _v in enumerate(alf):
        if v[0] == _v:
            v[0] = i
_sp = copy.copy(sp)
_sp.sort(reverse=True)

for v in _sp:
    for i, _v in enumerate(sp):
        if v == _v:
            print(i+1)

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

l = [input().split() for _ in range(n)]
for i in l:
    i[1] = -int(i[1])
    i.append(l.index(i))

l.sort()
for i in l:
    print(i[2] + 1)

Solution (Python):
import copy
N = int(input())
SP = [[] for _ in range(N)]
for i in range(N):
    SP[i] = list(input().split())
    SP[i][1] = int(SP[i][1])
    
unique = list(set(s[0] for s in SP))
unique.sort(reverse=True)
for i, uni in enumerate(unique):
    for j, S in enumerate(SP):
        if uni == S[0]:
            S[0] = i

copy_SP = copy.copy(SP)
SP.sort(reverse=True)
for i, c in enumerate(SP):
    for j, sp in enumerate(copy_SP):
        if c == sp:
            print(j+1)

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

Solution (Python):
from operator import itemgetter

N = int(input())
l = []
for i in range(N):
        s, p = input().split()
        p = int(p)
        l.append([s,p,1+i])
l.sort(key=itemgetter(0))
L = []
k = l[0][0]
ss = [l[0]]
for i in range(N-1):
        if l[i+1][0] == k :
                ss.append(l[i+1])
        else:
                L.append(ss)
                ss = [l[i+1]]
                k = l[i+1][0]
L.append(ss)
for i in L:
        i.sort(key=itemgetter(1), reverse=True)
for i in L:
        for j in range(len(i)):
                print(i[j][2])

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

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

list = [input().strip().split() for i in range(N)]

from operator import itemgetter

sort1 = sorted(list, key=lambda x: int(x[1]), reverse=True)
sort2 = sorted(sort1, key=itemgetter(0))

for i in range(N):
    print(list.index(sort2[i]) + 1)

Solution (Python):








class Guidebook(object):
    def __init__(self, num, city, score):
        self.num = num
        self.city = city
        self.score = score


def print_number(N, guidebook):
    for i in range(N):
        print(guidebook[i].num)


def score_sort(N, guidebook):
    for i in range(N-1):
        for j in range(N-1):
            if guidebook[j].score < guidebook[j+1].score:
                guidebook[j], guidebook[j+1] = (
                    guidebook[j+1], guidebook[j] )


def city_sort(N, guidebook):
    for i in range(N-1):
        for j in range(N-1):
            if str(guidebook[j].city) > str(guidebook[j+1].city):
                guidebook[j], guidebook[j+1] = (
                    guidebook[j+1], guidebook[j] )


if __name__ == '__main__':
    N = int(input()) 
    guidebook = []
    for i in range(N):
        s, p = input().split()
        restaurant = Guidebook(i+1, s, int(p))
        guidebook.append(restaurant)

    score_sort(N, guidebook)
    city_sort(N, guidebook)
    print_number(N, guidebook)

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 = int(input())
l = []
for i in range(n):
  s,p = 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 range(n):
  print(l[i][2])

Solution (Python):
n = int(input())
dat = []
for i in range(n):
    s,p = input().split()
    dat.append((s, int(p), i+1))
res = sorted(dat, key=lambda x: (x[0], -x[1]))
for i in range(len(res)):
    print(res[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 n: n[1], reverse=True)
sp.sort(key=lambda n: n[0])

for a in range(n):
    print(sp[a][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 n: n[1], reverse=True)
sp.sort(key=lambda n: n[0])

for c in range(n):
    sp[c].append(c + 1)

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

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

Solution (Python):
import sqlite3


connection = sqlite3.connect(':memory:')
cursor = connection.cursor()
cursor.execute("""
CREATE TABLE restaurant (
    id INTEGER,
    city TEXT NOT NULL,
    point INTEGER NOT NULL,
    PRIMARY KEY (id)
);
""")

N = int(input())
for i in range(N):
    Si, Pi = input().split()
    cursor.execute("INSERT INTO restaurant (id, city, point) VALUES ({}, '{}', {});".format(
        i + 1, Si, Pi
    ))

for row in cursor.execute("SELECT id FROM restaurant ORDER BY city ASC, point DESC;"):
    print(row[0])

Solution (Python):
n = int(input())
l = [[i for i in input().split()] + [j + 1] for j in range(n)]
l.sort(key=lambda x:x[0])

k = [0]
for i in range(len(l) - 1):
    l[i][1] = int(l[i][1])
    if (l[i][0] != l[i + 1][0]):
        k.append(i + 1)
l[-1][1] = int(l[-1][1])
k.append(len(l))

out = []
for i in range(len(k) - 1):
    a = l[k[i]:k[i + 1]]
    a.sort(reverse=True, key=lambda x:x[1])
    out += a

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

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

Solution (Python):
from operator import itemgetter
n = int(input())
s = []
for i in range(n) :
	a,b = input().split()
	s.append([i+1,a,int(b)])
s.sort(key=itemgetter(2),reverse=True)
s.sort(key=itemgetter(1))
print("\n".join(str(s[i][0]) for i in range(n)))

Solution (Python):
from operator import itemgetter

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

S.sort(key=itemgetter(2),reverse=True)
S.sort(key=itemgetter(1))

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

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

Solution (Python):
n = int(input())
SP = []
for _ in range(n):
    SP.append([i for i in input().split()])
for i in range(n):
    SP[i][1] = str(100 - int(SP[i][1])).rjust(3,'0')
SP2 = []
for i in range(n):
    SP2.append(SP[i][0]+SP[i][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

Solution (Python):
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

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

sp = []

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

sp.sort()

for s, p, x in sp:
    print(x)

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

restaurant = {}

for i in range(n):
    city, point = input().split()
    point = -int(point)
    restaurant[i] = (city, point)
    
restaurant = sorted(restaurant.items(), key=lambda x: x[1])

for i in restaurant:
    print(i[0]+1)

Solution (Python):
from collections import defaultdict


def main():
    n = int(input())
    d = defaultdict(list)
    for i in range(n):
        k, v = input().split()
        d[k].append((int(v), i+1))
    for k in sorted(d.keys()):
        for v in sorted(d[k], key=lambda x: x[0], reverse=True):
            print(v[1])

if __name__ == '__main__':
    main()

Solution (Python):

n = int(input())
d = []

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


d.sort()

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

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

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

for j in range(len(ls)):
    print(ls[j][0])

Solution (Python):
N=int(input())
List=[[0 for i in range(3)] for j in range(N)]
for i in range(N):
  S,P=input().split()
  List[i][0]=i+1
  List[i][1]=S
  List[i][2]=int(P)
List.sort(key=lambda x:x[2],reverse=True)
List.sort(key=lambda x:x[1])
for i in range(N):
  print(List[i][0])

Solution (Python):
from operator import itemgetter
print('\n'.join([l[2] for l in sorted([[l[0], -int(l[1]), str(l[2] + 1)] for l in [input().split() + [i] for i in range(int(input()))]],key=itemgetter(0, 1))]))

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

Solution (Python):


N = int(input())
List = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
    S,P=input().split()
    List[i][0] = i+1
    List[i][1] = S
    List[i][2] = int(P)
    
List.sort(key=lambda x:x[2], reverse=True)  
List.sort(key=lambda x:x[1])  

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

Solution (Python):


N = int(input())

P = [[0 for i in range(3)] for j in range(N)]

for i in range(N):
    P[i][0],P[i][1]  = input().split()
    P[i][1] = 100 - int(P[i][1])
    P[i][2] = i + 1

P.sort()

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

Solution (Python):
d = {}
n = int(input())
for i in range(n):
	s, x = input().split()
	x = int(x)
	if s in d:
		d[s].append([x, i])
	else:
		d[s] = [[x, i]]
a = []
for key in d:
	b = d[key]
	b.sort(reverse = True)
	a.append([key, b])
a.sort()
for x in a:
	for y in x[1]:
		print(y[1] + 1)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

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

for i in sorted(t):
    print(i[2])

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
s = [0] * n
p = [0] * n
for i in range(n):
    s[i], p[i] = input().split()
    p[i] = -(int(p[i]))

for i in sorted(zip(s,p,range(n))):
    print(i[2]+1)

Solution (Python):


n = int(input())
S=[]

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

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

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

Solution (Python):
from operator import itemgetter
N = int(input())
S = [""] * N
P = [0] * N
P2 = [""] * N
NUM = [0] * N
lst = [""] * N
for i in range(0, N):
    S[i], P2[i] = map(str, input().split())
    P[i] = int(P2[i])
    NUM[i] = i + 1
    lst[i] = (S[i], P[i], NUM[i])
sorted1 = sorted(lst, key=itemgetter(1), reverse=True)
sorted2 = sorted(sorted1, key=itemgetter(0))
for i in range(0,N):
     print(sorted2[i][2])

Solution (Python):
import functools as f

def to_num(a, b):
    if a > b:
        return 1
    if b > a:
        return -1
    return 0

def cmp(a, b):
    if (a[0] == b[0]):
        return to_num(b[1], a[1])
    return to_num(a[0], b[0])

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

A.sort(key=f.cmp_to_key(cmp))
for i in range(n):
    print(A[i][2])

Solution (Python):
print('\n'.join([l[2] for l in sorted(sorted([[l[0], int(l[1]), str(l[2] + 1)] for l in (input().split() + [i] for i in range(int(input())))], key=lambda l: l[1], reverse=True), key=lambda l: l[0])]))

Solution (Python):

N = int(input())
S = [""] * N
P = [0] * N
P2 = [""] * N
NUM = [0] * N
for i in range(0, N):
    S[i], P2[i] = map(str, input().split())
    P[i] = int(P2[i])
    NUM[i] = i + 1
for i in range(0, N):
    for j in range(1, N):
        if S[j] < S[j-1]:
            S[j-1], S[j] = S[j], S[j-1]
            P[j-1], P[j] = P[j], P[j-1]
            NUM[j-1], NUM[j] = NUM[j], NUM[j-1]
        if S[j] == S[j-1]:
            if P[j] > P[j-1]:
                S[j-1], S[j] = S[j], S[j-1]
                P[j-1], P[j] = P[j], P[j-1]
                NUM[j-1], NUM[j] = NUM[j], NUM[j-1]
for i in range(0,N):
    print(NUM[i])

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

print('\n'.join([str(t[2]+1) for t in sorted(l)]))

Solution (Python):
import sys
import bisect
from collections import defaultdict

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

a=sorted(a)

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

Solution (Python):
N = int(input())
A = []
B = []
C = []
for i in range(N):
    n,a=input().split()
    A.append(n)
    B.append(int(a))  
    C.append(i)
for i in range(N):
    c = i
    for k in range(i+1,N):
        if A[i] > A[k]:
            l = B[k]
            B[k] = B[i]
            B[i] = l
            l = A[k]
            A[k] = A[i]
            A[i] = l
            l = C[k]
            C[k] = C[i]
            C[i] = l
            
        elif A[i] == A[k]:
            if B[i] < B[k]:
                l = B[k]
                B[k] = B[i]
                B[i] = l
                l = A[k]
                A[k] = A[i]
                A[i] = l
                l = C[k]
                C[k] = C[i]
                C[i] = l
               

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

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

Solution (Python):
N = int(input())
SP = [list(input().split()) for _ in range(N)]

for x in sorted((S, -int(P), i) for i, (S, P) in enumerate(SP, 1)):
    print(x[2])

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

Solution (Python):
import sys
N = int(sys.stdin.readline())
R = {}
for i in xrange(N):
  s, p = sys.stdin.readline().strip().split()
  if s in R:
    R[s] += [(int(p), i+1)]
  else:
    R[s] = [(int(p), i+1)]
for k,V in sorted(R.items()):
  for v in sorted(V, reverse=True):
    print v[1]

Solution (Python):
from operator import itemgetter

N = int(input())
ins = [list(input().split()) for _ in range(N)]

res = []
for i, row in enumerate(ins):
    row = [i+1] + [row[0]] + [int(row[1])]
    res.append(row)


res.sort(key=itemgetter(2), reverse=True)


res.sort(key=itemgetter(1))

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

Solution (Python):

"""
Created on Mon May 27 22:22:26 2019

@author: Yamazaki Kenichi
"""
def _int(x):
    try:
        return int(x)
    except:
        return x

N = int(input())
sp = [list(map(_int,input().split()))+[i+1] for i in range(N)]

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):

"""
Created on Mon May 27 22:22:26 2019

@author: Yamazaki Kenichi
"""
def _int(x):
    try:
        return -int(x)
    except:
        return x

N = int(input())
sp = [list(map(_int,input().split()))+[i+1] for i in range(N)]




sp.sort()

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

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

Solution (Python):
n = int(input())
numList=[i+1 for i in range(n)]
strList=[]
pointList=[]
for i in range(n):
  s,p = input().split()
  strList.append(s)
  pointList.append(-int(p))
lists = zip(strList,pointList,numList)
q=sorted(lists)
c,a,b = zip(*q)
for x in b:
  print(int(x))

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

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

for n in range(N):
    print(S_P[n][2])

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

lst.sort()
for i in range(N):
    print(lst[i][2])

Solution (Python):

import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    L = [0] * N
    for i in range(N):
        s, p = i2s().split()
        L[i] = (s, int(p), i + 1)

    L.sort(key=lambda x: (x[0], -x[1]))
    for l in L:
        print(l[2])

main()

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

sp.sort()
for item in sp:
    print(item[1])

Solution (Python):
import sys

N = int(sys.stdin.readline())

l = {}
for i in range(0, N):
    s, p = sys.stdin.readline().split(" ")
    p = int(p)
    if s not in l:
        l[s] = []
    l[s].append([i, p])


l = sorted(l.items(), key=lambda x: x[0])
for ll in l:
    r = sorted(ll[1], key=lambda x: x[1], reverse=True)
    for rr in r:
        print(rr[0] + 1)

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

for i in range(n):
    x, y = input().split()
    y = int(y)
    sp.append((x, y, i))

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

for x, y, i in sp:
    print(i+1)

Solution (Python):
N = int(input())
A = []
for i in range(N):
	tem_data = input().split()
	A.append([tem_data[0] , int(tem_data[1]) , i+1])
A = sorted(A , key = lambda x: (x[0] , -x[1]))
for name , score  , number in A:
	print(number)

Solution (Python):


n = int(raw_input())

lst = []

for i in xrange(n):
 name,p=map(str,raw_input().split())
 lst.append([i+1,name,int(p)])
lst.sort(key=lambda x:(x[1],-x[2]))
for i in xrange(n):
  print lst[i][0]

Solution (Python):
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''

from collections import Counter
gi = lambda : list(map(int,input().strip().split()))
n, = gi()
l = [input().split() for _ in range(n)]
l = [(l[k][0], -int(l[k][1]), str(k+1)) for k in range(n) ]
l.sort()
print("\n".join([e[2] for e in l]))

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

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

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

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

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

Solution (Python):
l=[]
for i in range(int(input())):
    a,b=input().split()
    l.append([a,-int(b),i+1])
l.sort(key=lambda x:x[1])
l.sort()
for a,b,c in l:print(c)

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=int(input())
q=[input().split() + [i] for i in range(n)]
for i in range(n):
    q[i][1]=int(q[i][1])
list_point = sorted(q, key=lambda x:x[1], reverse=1)
list_city = sorted(list_point, key=lambda x:x[0], reverse=0)
for s,t,r in list_city:
    print(r+1)

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

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

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

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

SN.sort()


start = 0
while (start < N-1):
  for i in range(start, N):
    search = SN[start][0]
    while(SN[i][0] == search):
      end = i
      if(i<N-1):
        i = i+1
      else:
        end = i
        break
        
  SNpart = SN[start:min(end+1, N)]
  
  SNpart.sort(key=lambda x:-x[1])
  SN[start:min(end+1, N)] = SNpart

  
  start = end+1

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

Solution (Python):
print('\n'.join([l[2] for l in sorted(sorted([[l[1][0], int(l[1][1]), str(l[0] + 1)] for l in enumerate(input().split() for _ in range(int(input())))], key=lambda l: l[1], reverse=True), key=lambda l: l[0])]))

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

Solution (Python):
N = int(input())
cps = {}
for i in range(1,N+1):
    city,point = input().split()
    point = int(point)
    if city in cps:
        cps[city].append((point,i))
    else:
        cps[city] = [(point,i)]
for k in sorted(cps.keys()):
    for v,idx in sorted(cps[k], reverse=True):
        print(idx)

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

R = [input().split()+[i] for i in range(1, N+1)]

R = [[r[0], int(r[1]), r[2]] for r in R]

city = ''
stars = []
for r in sorted(R):
  if city != r[0]:
    for star in reversed(stars):
      print(star)
    city = r[0]
    stars = [r[2]]
  else:
    stars.append(r[2])
for star in reversed(stars):
  print(star)

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

Solution (Python):
n = int(input())
arr = []
for i in range(n):
    arr.append([i + 1] + list(input().split(" ")))
arr = [(a, b, -int(c)) for (a, b, c) in arr]
sarr = sorted(arr, key=lambda x: (x[1], x[2]))

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

Solution (Python):
from collections import defaultdict
N = int(input())
dic = defaultdict(list)
for n in range(1, N + 1):
    s, p  = input().split()
    p = int(p)
    dic[s].append((p, n))
for s in sorted(dic.keys()):
    lis = sorted(dic[s])[::-1]
    for _, p in lis:
        print(p)

Solution (Python):
from operator import itemgetter, attrgetter
N = int(input())
A = []
for i in range(N):
    tmp = input().split()
    A.append([tmp[0],-int(tmp[1]),i])
A.sort()
A.sort(key=itemgetter(0,1))
for i in range(N):
    print(A[i][2]+1)

Solution (Python):
def main():
	'''
	メイン関数
	'''
	
	N = int(input())
	
	SPList_reverse = []

	for n in range(0,N):
		SP = input().split()
		sp_tuple_reverse = SP[0], (100-int(SP[1]))
		SPList_reverse.append(sp_tuple_reverse)


	sortedSPList = sorted(SPList_reverse)


	for ssp in sortedSPList :
		ori = ssp[0], int(ssp[1])
		print(SPList_reverse.index(ori)+1)



if __name__ == '__main__':
	main()

Solution (Python):
def main():
	'''
	メイン関数
	'''
	
	N = int(input())
	
	SPList = []
	SPList_reverse = []

	for n in range(0,N):
		SP = input().split()
		sp_tuple = SP[0], int(SP[1])
		sp_tuple_reverse = SP[0], (100-int(SP[1]))
		SPList.append(sp_tuple)
		SPList_reverse.append(sp_tuple_reverse)


	sortedSPList = sorted(SPList_reverse)


	for ssp in sortedSPList :
		ori = ssp[0], int(ssp[1])
		print(SPList_reverse.index(ori)+1)



if __name__ == '__main__':
	main()

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

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

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

Solution (Python):
import numpy
n=int(input())
data=[0]*n
for i in range(n):
    data[i]=input().split()

ans=numpy.empty((n,2))
for i in range(n):
    ans[i][1]=i
    ans[i][0]=int(data[i][0].upper().ljust(10,'0'),36)+100-int(data[i][1])
Ans=sorted(ans,key=lambda x:x[0])
for i in range(n):
    print(int(Ans[i][1])+1)

Solution (Python):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)


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 range(N):
	print(A[i][2])

Solution (Python):
from sys import stdin
from collections import defaultdict

N = int(input())
lines = stdin.readlines()

dic = defaultdict(dict)

for i, line in enumerate(lines):
    line = line.strip().split()
    if i==0:
        tuple1 = ([i+1, line[0], int(line[1])],)
    else:
        tuple1 = tuple1 + ([i+1, line[0], int(line[1])],)




tuple1 = sorted(tuple1, key = lambda x:x[2], reverse=True)
result = sorted(tuple1, key = lambda x:x[1])
for i in range(0,N):
    print(result[i][0])

Solution (Python):

N = int(input().rstrip())

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

Index = sorted(range(N), key=lambda i: P[i], reverse=True)
Last_Index = sorted(Index, key=lambda i: S[i])

for i in Last_Index:
    print(i + 1)

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())
X = [list(input().split()) for _ in range(n)]


xx = [0]*n
for i in range(n):
    X[i][1] = int(X[i][1])
    xx[i] = int(X[i][1])


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

for i in range(n):
    print(xx.index(L[i][1]) + 1)

Solution (Python):
import numpy as np

s = np.array([input().split() for _ in range(int(input()))])
s = [i[0]+"{0:03d}".format(100-int(i[1])) for i in s]
s = np.argsort(s,axis=0)

for i in s:
    print(i+1)

Solution (Python):

import os
import time
import re
import math


N = int(input())
SP=[]
for a in range(N):
    temp=input().split()
    SP.append([temp[0],int(temp[1]),(a+1)])

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

Solution (Python):
n = int(input())
s = [[int(i) if str.isnumeric(i) else i for i in input().split()] for i in range(n)]

k = 1
for row in s:
    row.append(k)
    k += 1

s.sort(reverse=True)
s.sort(key=lambda x: x[0])

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

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

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

Solution (Python):
import numpy as np
N = int(input())
a = []
for i in range(N):
  S, P = input().split()
  a.append((S, 100-int(P), i+1))
a.sort()
for i in a:
  print(i[2])

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

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

Solution (Python):

N = int(input())
cnt = 1

datalist =[ list(map(str, input().split())) for i in range(N) ]

for i in range(0,N):
    datalist[i].append(cnt)
    cnt += 1

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

for i in range(0,N):
    print(datalist2[i][2])

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

Solution (Python):
from collections import defaultdict
N=int(input().strip())
points=defaultdict(list)
for i in range(N):
    S,P=input().strip().split()
    P=int(P)
    points[S].append((i+1,P))
for s in sorted(points.keys()):
    shps=points[s]
    for sh in sorted(shps,key=lambda x:-x[1]):
        print(sh[0])

Solution (Python):
import operator
N = int(input())
rests = []
for i in range(N):
  S, P = input().split()
  P = int(P)
  rest = (i + 1, S, P)
  rests.append(rest)
rests = sorted(rests, key = operator.itemgetter(2), reverse=True)
rests = sorted(rests, key = operator.itemgetter(1))
for row in rests:
  print(row[0])

Solution (Python):
N = int(input())
res = []
for i in range(N):
    name, point = input().split()
    point = int(point)
    res.append((name, point, len(res) + 1))
res = sorted(res, key=lambda x: (x[0], -x[1]))
for name, point, idx in res:
    print(idx)

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

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

mylist.sort()
for i in mylist:
  print(i[2])

Solution (Python):
from operator import itemgetter

n = int(input())
a = []

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

b = sorted(a,key=itemgetter(1),reverse=True)
xs = sorted(b,key=itemgetter(0))
for x in xs:
    print(x[2])

Solution (Python):
N = int(input())
li = []
cities = []
for i in range(N) :
    inp = input().split()
    l = [inp[0], int(inp[1]), int(i+1)]
    li.append(l)
    if (l[0] not in cities) :
        cities.append(l[0])

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

ans = []
for c in cities :
    
    ans += sorted(list(filter(lambda x : x[0] == c, li)),key=lambda x: x[1], reverse=True)
    

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