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



Sample input:
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40


Sample output:
3
4
6
1
5
2

Submission status: Runtime Error

Solution code:
import numpy as np
import pandas as pd

n = int(input())
SP = pd.DataFrame(np.array([[i for i in input().split()] for i in range(n)] ))

SP1=SP.sort_values(1,ascending=False)
SP2=SP1.sort_values(0)

num=SP2.index

for i in range(n):
    print(int(num[i])+1)

Submission status: Runtime Error

Solution code:
import pandas as pd
n = int(input())
arr_ = [[str(i) for i in input().split()] for _ in range(n)]
arr = pd.DataFrame(arr_)
arr[2] = [i for i in range(n)]
num = arr.sort_values(by=1,ascending=False)
name = num.sort_values(by=0,ascending=True)
name.index = [i for i in range(n)]
for i in range(n):
    print(name[2][i]+1)

Submission status: Runtime Error

Solution code:
import numpy as np
import pandas as pd

n = int(input())
SP = pd.DataFrame(np.array([[i for i in input().split()] for i in range(n)] ))

SP1=SP.sort_values(1,ascending=False)
SP2=SP1.sort_values(0)

num=SP2.index[0]

for i in range(n):
    print(num[i]+1)

Submission status: Runtime Error

Solution code:
N =int(raw_input())
S =[]
P =[]
for i in range(N):
    s,p=map(str,raw_input().split())
    S.append(s)
    P.append(p)
ss=sorted(list(set(S)))
for i in range(len(ss)):
    a =[]
    b =[]
    for j in range(N):
        if ss[i]==S[j]:
            a.append(j)
            b.append(P[i])
    c = sorted(b).reverse()
    for k in c:
        for j in range(len(b)):
            if k == b[j]:
                print(a[j])

Submission status: Runtime Error

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

hoge = sorted(SP, key = lambda x:x[1], reverse = True)
SPsort = sorted(hoge, key = lambda x:x[0]

for i in range(N):
    print(SP.index(SPsort[i]) + 1)

Submission status: Runtime Error

Solution code:
N =int(raw_input())
S =[]
P =[]
for i in range(N):
    s,p=map(str,raw_input().split())
    S.append(s)
    P.append(p)
ss=sorted(list(set(S)))
for i in range(len(ss)):
    a =[]
    b =[]
    for j in range(100):
        if ss[i]==S[j]:
            a.append(j)
            b.append(P[i])
    c = sorted(b).reverse()
    for k in c:
        for j in range(len(b)):
            if k == b[j]:
                print(a[j])

Submission status: Runtime Error

Solution code:

def anprint():
    global fin
    b = -1
    p = -1
    for i in range(n):
        if lst[i][1] > b:
            p = i
            b = lst[i][1]
    print(p+1)
    lst[p][1] = 0
    fin -= 1
    if fin>0:
        anprint()




n = int(input())
lst = []
ans = []
for i in range(n):
    lst.append(input().split())
    ans.append(0)
    for k in range(len(lst[i][0])):
        lst[i][1] = int(lst[i][1])
        if lst[i][1] = 0:
            lst[i][1] += 0.5
        if lst[i][0][k] == 'a':
            lst[i][1] += 25*26**(9-k)*100
        elif lst[i][0][k] == 'b':
            lst[i][1] += 24*26**(9-k)*100
        elif lst[i][0][k] == 'c':
            lst[i][1] += 23*26**(9-k)*100
        elif lst[i][0][k] == 'b':
            lst[i][1] += 22*26**(9-k)*100
        elif lst[i][0][k] == 'e':
            lst[i][1] += 21*26**(9-k)*100
        elif lst[i][0][k] == 'f':
            lst[i][1] += 20*26**(9-k)*100
        elif lst[i][0][k] == 'g':
            lst[i][1] += 19*26**(9-k)*100
        elif lst[i][0][k] == 'h':
            lst[i][1] += 18*26**(9-k)*100
        elif lst[i][0][k] == 'i':
            lst[i][1] += 17*26**(9-k)*100
        elif lst[i][0][k] == 'j':
            lst[i][1] += 16*26**(9-k)*100
        elif lst[i][0][k] == 'k':
            lst[i][1] += 15*26**(9-k)*100
        elif lst[i][0][k] == 'l':
            lst[i][1] += 14*26**(9-k)*100
        elif lst[i][0][k] == 'm':
            lst[i][1] += 13*26**(9-k)*100
        elif lst[i][0][k] == 'n':
            lst[i][1] += 12*26**(9-k)*100
        elif lst[i][0][k] == 'o':
            lst[i][1] += 11*26**(9-k)*100
        elif lst[i][0][k] == 'p':
            lst[i][1] += 10*26**(9-k)*100
        elif lst[i][0][k] == 'q':
            lst[i][1] += 9*26**(9-k)*100
        elif lst[i][0][k] == 'r':
            lst[i][1] += 8*26**(9-k)*100
        elif lst[i][0][k] == 's':
            lst[i][1] += 7*26**(9-k)*100
        elif lst[i][0][k] == 't':
            lst[i][1] += 6*26**(9-k)*100
        elif lst[i][0][k] == 'u':
            lst[i][1] += 5*26**(9-k)*100
        elif lst[i][0][k] == 'v':
            lst[i][1] += 4*26**(9-k)*100
        elif lst[i][0][k] == 'w':
            lst[i][1] += 3*26**(9-k)*100
        elif lst[i][0][k] == 'x':
            lst[i][1] += 2*26**(9-k)*100
        elif lst[i][0][k] == 'y':
            lst[i][1] += 1*26**(9-k)*100


fin = n
anprint()

Submission status: Runtime Error

Solution code:
from sys import stdin


def sortFirst(val):
    return val[0]
N=stdin.readline().rstrip()
N=int(N)
l={}
for i in range(1,N+1):
    S,P = stdin.readline().rstrip().split()
    if S in l.keys():
        l[S].append([int(P),i])

    else:
        l[S]=[[int(P),i]]


for key in l.keys():
    l[key].sort(key=sortFirst,reverse=True)
for key in sorted(l):
    for val in l[key]:
        print "%d"%(val[1])

Submission status: Runtime Error

Solution code:
n=int(input())
sp=[list(map(str,input().split())) for i in range(n)]

for i in range(n):
    sp[i][1]=1/int(sp[i][1])
ps=sorted(sp)
for i in range(n):
    print(sp.index(ps[i])+1)

Submission status: Runtime Error

Solution code:
 N = int(input())
 SP = [list(map(str, input().split())) for _ in range(N)]

 for i in range(N):
   SP[i].append(i+1)
   SP[i][1] = int(SP[i][1])*(-1)

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

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

Submission status: Runtime Error

Solution code:

n = input()
list = []

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

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

Submission status: Runtime Error

Solution code:
N = int(input())

dic = {}
order = []
for i in range(1,N+1):
    s, p = map(str, input().split())
    p = int(p)
    order.append((s, p))
    if dic.get(s) is None:
        dic[s] = [(i, p)]
    else:
        dic[s].append((i, p))

for k in dic:
    tmp = dic[k][:]
    tmp2 = sorted(tmp, key=lambda x: -x[1])
    dic[k] = tmp2

inds = []
ind = 1
for k in sorted(dic.keys(), key=lambda x: x[1]):
    for t in dic[k]:
        inds.append((t[0], ind))
        ind += 1

for ind in sorted(inds, key=lambda x: x[1]):
    print(ind[0])

Submission status: Runtime Error

Solution code:
N = int(input())
a = []
for x in range(N):
	i = x + 1
	a.append(list(input().split()).extend([i]))
print(a)
sorted(a, key=lambda x:(x[0],x[1]), reverse=True)
for review in a:
	print(review[2])

Submission status: Runtime Error

Solution code:
import collections
def sortFirst(val):
    return val[0]
N=raw_input("")
N=int(N)
l={}
for i in range(1,N+1):
    S,P = raw_input("").split(' ')
    if S in l.keys():
        l[S].append([int(P),i])

    else:
        l[S]=[[int(P),i]]


for key in l.keys():
    l[key].sort(key=sortFirst,reverse=True)
for key in sorted(l):
    for val in l[key]:
        print "%d"%(val[1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = list(map(int,input().split()))

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

Submission status: Runtime Error

Solution code:

n = input()
list = []

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

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

Submission status: Runtime Error

Solution code:
import pandas as pd

N = int(input())
rest = [list(input().split()) for n in range(N)]

df_rest = pd.DataFrame(rest)
df_rest[1] = df_rest[1].apply(int)
df_rest = df_rest.sort_values([0,1], ascending = [True, False])

for x in df_rest.index:
    print(x + 1)

Submission status: Runtime Error

Solution code:

n = input()
list = []

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

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

Submission status: Runtime Error

Solution code:
#%%
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = list(map(int,input().split()))

print(A)

Submission status: Runtime Error

Solution code:
import pandas as pd
N = int(input())
S=[]
P=[]
for ii in range(N):
    SS,PP = map(str,input().split())
    S.append(SS)
    P.append(int(PP))
    
df = pd.DataFrame({'city':S,'point':P})
df.sort_values(by=['city','point'],ascending =[True,False],inplace=True)
df['num']=list(df.index)
df['num']=df['num']+1
for num in df['num']:
    print(num)

Submission status: Runtime Error

Solution code:

n = input()
list = []

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = list(map(int,input().split()))

print(A.sort())

Submission status: Runtime Error

Solution code:
N = int(input())
S_P = []
for i in range(N):
    S , P = input().split()
    S_P.append([ S , int(P) , i])
S_P.sort( key = lambda x : x[0] )
state = S_P[0][0]
S_P_sort = []
temp = []
for S , P , i in S_P:
    if S != state:
        temp.sort( key = lambda x : x[1])
        S_P_sort.extend(temp)
        S_P_sort.append([S , P, i])
        state = S
        temp = []
    else:
        temp.append([S , P, i])
for j in range(N):
    print(S_P_sort[j][2]+1)

Submission status: Runtime Error

Solution code:
N = int(input)

data=[]
for i in range(N):
    S,P = input().split()
    li = [i,S,int(P)]
    data.append(li)
    
data.sort(key=lambda x: x[1])
data.sort(reverse=True, key=lambda x: x[2])
for i in range(N):
    data[i] = data[i]+[i]

data.sort(key=lambda x: x[0])
for i in range(N):
    print(str(data[i][3]))

Submission status: Runtime Error

Solution code:

N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = list(map(int,input().split()))

A.sort()
print(A)

Submission status: Runtime Error

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

SPsort = sorted(SP, key = lambda x:x[0])

for i in range(N):
    print(SP.index(SPsort[i])) + 1

Submission status: Runtime Error

Solution code:
l = []
for i in range(int(input())):
  s,p = map(str, input().split())
  l.append((s,100-int(p),i+1))
m = sorted(l)
for i in l:
  print(l[2])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import pandas as pd
n = int(input())
dic = {}
for i in range(n):
    dic[i+1] = {}
    dic[i+1]["city"], dic[i+1]["score"] = input().split()
print(*list(pd.DataFrame().from_dict(dic, orient="index").sort_values(["city","score"], ascending=[True,False]).index), sep="\n")

Submission status: Runtime Error

Solution code:
n = int(input())
sp = [input().split() for i in range(n)]

sorted_sp = sorted(sp,key = lambda x: int(x[1]), reverse=True)
sorted_sp = sorted(sorted_sp,key = itemgetter(0))

for i in range(n):
    for j in range(n):
        if sp[j] == sorted_sp[i]:
            print(j+1)

Submission status: Runtime Error

Solution code:
N = int(input())
R = []
for i in range(N):
  l = input().split()
  R.append((l[0], (-1)*int(l[1]), i))

R.sort()
for i in range(N):
  print(R[2]+1)

Submission status: Runtime Error

Solution code:
n = int(raw_input())
r = []
for i in xrange(1,n+1):
	rest,score = raw_input().split()
	score=int(score)
	r.append((rest,score,i))
r = sorted(r,key=lambda x:(x[0], -x[1], x[2]))
for x in r:
	print x[2]cd

Submission status: Runtime Error

Solution code:
N = int(input())
List = [list(map(int,input().split())) for i in range(N)]

for i in range(N):
    List[i].append(i+1)
List.sort(key=lambda x:x[1], reverse=True)
List.sort(key=lambda x:x[0])
for i in range(N):
    print("{}".format(List[i][2]))

Submission status: Runtime Error

Solution code:
N = int(input())
X = []
for i in range(N):
	s, p = input()
	X.append([s, p,  i+1])
X.sort()
s = X[0][0]
for i in range(N):
	j = i
	while True:
		if j == len(X) - 1:
			break
		if X[j][0] != s:
			j -= 1
			break
		else j += 1
	for k in range(j-i+1):
		print(X[j][2])
		j -= 1

Submission status: Runtime Error

Solution code:
n = int(input())
sp = [list(map(int, input().split())) for _ in range(n)]

d = sorted(sp, key=lambda x:(x[0],-x[1]))
for i in range(len(sp)):
    print(sp.index(d[i]))

Submission status: Runtime Error

Solution code:
N = int(input())
X = []
for i in range(N):
	s, p = input()
	X.append([s, p,  i+1])
X.sort()
s = X[0][0]
for i in range(N):
	j = i
	while True:
		if j == len(X) - 1:
			break
		if X[j][0] != s:
			j -= 1
			break
	for k in range(j-i+1):
		print(X[j][2])
		j -= 1

Submission status: Runtime Error

Solution code:
n = int(input())
sp = [list(map(int, input().split())) for _ in range(n)]

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

Submission status: Runtime Error

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

for s in sorted(dict.keys()):
    for (p, i) in reversed(sorted(dict[s])):
        print(i)

Submission status: Runtime Error

Solution code:
N = int(input())
rs = []
for _ in range(N):
  s, p = map(int, input().split())
  rs.append((i+1, s, p))

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

Submission status: Runtime Error

Solution code:
N = int(input())
Ss = []
for i in range(N):
    Ss.append((i+1, *input().split(" ")))

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

Submission status: Runtime Error

Solution code:
input_AP = list(map(int, input().split()))
print(result)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
n = int(input())
res = [(i, *input().split()) for i in range(n)]

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
city_score = {}
for i in range(n):
	city, score = input.split()
    city_score[city] = city_score.get(city, []). + [(int(score), i)]

for city in sorted(city_score.keys()):
  for score in sorted(city_score[city]):
    print(score[1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key=lambda x: (x[0], -x[1]))
for a, b in X:
  print(a, b)