CodeEff/ECCO huggingface dataset:
# Original solution
n=int(eval(input()))
s=[[j for j in input().split()] for i in range(n)]
for i in range(n):
    s[i][1]=int(s[i][1])
    s[i].append(i)
s.sort(reverse=True,key=lambda x: x[1])
s.sort(key=lambda x: x[0])
for i in range(n):
    print((s[i][2]+1))

# Optimized solution
n=int(eval(input()))
a=[list(input().split())+[i] for i in range(n)]
for i in range(n):
  a[i][1]=-int(a[i][1])
a.sort()
for _,_,i in a:
  print((i+1))
# Original solution
n=int(eval(input()))
l=[]
for i in range(n):
    s,p=[x for x in input().rstrip().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,x,z in l:
    print(z)




# Optimized solution
n=int(eval(input()))
l=[]
for i in range(n):
  s,p=[x for x in input().rstrip().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 s,p,i in l:
  print(i)
# Original solution
n = int(eval(input()))
sp = [input().split() for _ in range(n)]

a = []
for s,p in sp:
  a.append([s, 100-int(p)])
A = sorted(a)
for i in range(n):
  print((a.index(A[i])+1))

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

b = sp[0][0]
I = 0
ans = []
for s,p,i in sp:
  if b == s:
    ans.insert(I, i)
  else:
    ans.append(i)
    b = s
    I = len(ans)-1
print(("\n".join(map(str, ans))))
# Original solution
n = int(eval(input()))
spi = []
for i in range(n):
    s,p = input().split()
    spi.append([s,int(p), i+1])
spi.sort()
before = spi[0][0]
ans = [spi[0][2]]
for s,p,i in spi[1:]:
    if s == before:
        ans.append(i)
    else:
        for x in ans[::-1]:
            print(x)
        before = s
        ans = [i]
for x in ans[::-1]:
    print(x)

# Optimized solution
n = int(eval(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]))
# Original solution
import collections
from operator import itemgetter
N = int(eval(input()))
SP = []
for i in range(N):
    s,p = input().split()
    SP.append([0,0])
    SP[i][0] = s
    SP[i][1] = int(p)
SP_new = sorted(SP)
t = 0
for i in range(N):
    if t > 0:
        t -= 1
        continue
    s = SP_new[i][0]
    t = 0
    for j in range(i+1, N):
        if s == SP_new[j][0]:
            t += 1
        else:
            break
    SP_new_new = SP_new[i:i+t+1]
    SP_new_new.sort(key = itemgetter(1))
    for k in range(1,len(SP_new_new)+1):
        u = SP_new_new[-k]
        print((SP.index(u)+1))


# Optimized solution
N = int(eval(input()))
SP = []
for i in range(N):
    s,p = input().split()
    SP.append([0,0])
    SP[i][0] = s
    SP[i][1] = -int(p)
SP_new = sorted(SP)
for i in SP_new:
    print((SP.index(i)+1))
# Original solution
# ABC 128: B – Guidebook
from operator import itemgetter

n = int(eval(input()))

s = []
p = []

for _ in range(n):
    tmp = [s for s in input().split()]
    s.append(tmp[0])
    p.append(int(tmp[1]))

restaurants = []
for i in range(n):
    restaurants.append([i + 1, s[i], p[i]])

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

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

# Optimized solution
# ABC 128: B – Guidebook
N = int(eval(input()))

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

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

for k in [shop[0] for shop in shops]:
    print(k)
# Original solution
N = int(eval(input()))

xy = []
for i in range(N):
    x, y = list(map(str, input().split()))
    y = int(y)
    xy.append([x, y])

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

for i in range(N):
    for j in range(N):
        if sort_xy[i][0] == xy[j][0]:
            if sort_xy[i][1] == xy[j][1]:
                print((j + 1))

# Optimized solution
N = int(eval(input()))

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

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

for i in range(N):
    print((sort_xy[i][0]))
# Original solution
n = int(eval(input()))
l = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    l.append([s, -p, i + 1])

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

# Optimized solution
n = int(eval(input()))
l = []
for i in range(n):
    s, p = input().split()
    p = -int(p)
    l.append([s, p, i + 1])

l.sort()
for i in l:
    print((i[2]))
# Original solution
N = int(eval(input()))

S = [""] * N
P = [0] * N

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


new_S = sorted(S)

same_v = []
same_i = []
for i, name in enumerate(new_S):
    for k in range(N):
        if new_S[i] == S[k]:
            same_v.append(P[k])
            same_i.append(k)
    x = same_i[same_v.index(max(same_v))]
    print((x + 1))
    same_v = []
    same_i = []
    P[x] = -1

# Optimized solution
N = int(eval(input()))

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

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

for _, _, i in new_SP:
    print(i)
# Original solution
n = int(eval(input()))
dic = [[x for x in input().split()] for i in range(n)]

for i in range(n):
    dic[i][1] = int(dic[i][1])
    dic[i].append(i + 1)

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

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

# Optimized solution
n = int(eval(input()))
dic = []

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

for i in range(n):
    print((dic[i][2]))
# Original solution
n = int(eval(input()))
dic = []

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

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

# Optimized solution
n = int(eval(input()))
dic = []

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

for i in range(n):
    print((dic[i][2]))
# Original solution
def main(N, lst):
    L = []
    for i in range(len(lst)):
        target = lst[i]
        L.append({"id":i+1, "store":target[0], "point":int(target[1])})
        L.sort(key = lambda x:x["point"], reverse = True)
        L.sort(key = lambda x:x["store"])
    for i in range(len(L)):
        print((L[i]["id"]))

N = int(eval(input()))
lst = list(list(map(str, input().split())) for _ in range(N))
main(N, lst)

# Optimized solution
def main(N, lst):
    L = []
    for i in range(len(lst)):
        target = lst[i]
        L.append({"id":i+1, "store":target[0], "point":int(target[1])})
    L.sort(key = lambda x:x["point"], reverse = True)
    L.sort(key = lambda x:x["store"])
    for i in range(len(L)):
        print((L[i]["id"]))

N = int(eval(input()))
lst = list(list(map(str, input().split())) for _ in range(N))
main(N, lst)
# Original solution
n = int(eval(input()))
d = [list(map(str, input().split())) for i in range(n)]
for i in range(1, n+1):
    d[i-1].append(i)
    d[i-1][1] = int(d[i-1][1])
d.sort()
ans = []
tmp = []
now_city = d[0][0]
for i in range(n):
    if now_city == d[i][0]:
        tmp.append(d[i])
    else:
        tmp.sort(key=lambda x: x[1], reverse=True)
        for j in range(len(tmp)):
            ans.append(tmp[j][2])
        tmp = []
        tmp.append(d[i])
        now_city = d[i][0]
tmp.sort(key=lambda x: x[1], reverse=True)
for j in range(len(tmp)):
    ans.append(tmp[j][2])
for i in ans:
    print(i)

# Optimized solution
n = int(eval(input()))
ans = []
for i in range(n):
    c, p = input().split()
    p = int(p)
    ans.append([c, -p, i+1])
ans.sort()
for _ in ans:
    print((_[2]))
# Original solution
N = int(eval(input()))
MAIN = []
for i in range(N):
    S,P = list(map(str,input().split()))
    MAIN.append([i+1,S,int(P)])

def swap(i,j):
    x = MAIN[i]
    MAIN[i] = MAIN[j]
    MAIN[j] = x

update = True
while update == True:
    update = False
    for i in range(1,N):
        if MAIN[i][1] > MAIN[i-1][1]:
            continue
        elif MAIN[i][1] == MAIN[i-1][1]:
            if MAIN[i][2] > MAIN[i-1][2]:
                swap(i,i-1)
                update = True
        else:
            swap(i,i-1)
            update = True


for m in MAIN:
    print((m[0]))

# Optimized solution
N = int(eval(input()))
MAIN = []
for i in range(N):
    S,P = list(map(str,input().split()))
    MAIN.append([S,-int(P)])

ans = sorted(MAIN)
for m in ans:
    print((MAIN.index(m) + 1))
# Original solution
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    SP =[]
    for i in range(N):
        SP.append([S[i],P[i]])

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

    # print(t)

    ans = []
    for x in t:
        for j in range(N):
            x1,x2 = x
            if(x1 == S[j] and x2 == P[j]):
                ans.append(j+1)


    for i in ans:
        print(i)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [str()] * (N)  # type: "List[str]" 
    P = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, S: "List[str]", P: "List[int]"):
    sp = [[i, S[i], P[i]] for i in range(N)]

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

    for i in range(N):
        print((sp[i][0]+1))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [str()] * (N)  # type: "List[str]"
    P = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()
# Original solution
n = int(eval(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]))

# Optimized solution
n = int(eval(input()))
ls = []
for i  in range(1,n+1):
    s,p = input().split()
    ls.append([i, s, int(p)])
    
ans = sorted(ls, key=lambda x: (x[1], -x[2]))
for j in range(n):
    print((ans[j][0]))
# Original solution
n = int(eval(input()))

l = []
ans = []

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

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

# Optimized solution
n = int(eval(input()))

l = []

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

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

for j in l:
    print((j[2]))
# Original solution
N = int(eval(input()))
SP = [input().split() for _ in range(N)]

L = []
for i in range(N):
  L.append([SP[i][0], int(SP[i][1]), 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]))

# Optimized solution
N = int(eval(input()))
SP = [list(input().split()) + [i + 1] for i in range(N)]

for i in range(N):
  SP[i][1] = -int(SP[i][1])

SP.sort()

for i in range(N):
  print((SP[i][2]))
# Original solution
N = int(eval(input()))
SP = [[x+1] + list(input().split()) for x in range(N)]

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

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


# Optimized solution
N = int(eval(input()))
S = sorted((list((lambda y: (y[0], -int(y[1]), x))(input().split()))) for x in range(1, N+1))

for x in S:
  print((x[2]))
# Original solution
n = int(eval(input()))
s = []
p = []
ans = [0]*n
for i in range(n):
    s1,p1 = [str(i) for i in input().split()]
    s.append(s1)
    p.append(p1)
    ans[i] = i + 1
for i in range(n):
    p[i] = int(p[i])
flag = 1
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if s[i] < s[i-1]:
            s[i],s[i-1] = s[i-1],s[i]
            p[i],p[i-1] = p[i-1],p[i]
            ans[i],ans[i-1] = ans[i-1],ans[i]
            flag = 1
flag = 1
while flag:
    flag = 0
    for i in range(n-1):
        if s[i] == s[i+1] and p[i] < p[i+1]:
            p[i],p[i+1] = p[i+1],p[i]
            ans[i],ans[i+1] = ans[i+1],ans[i]
            flag = 1
for i in range(n):
    print((ans[i]))

# Optimized solution
n = int(eval(input()))
ans = [[] for i in range(n)]
for i in range(n):
    ss,pp = list(map(str,input().split()))
    ans[i].append(ss)
    ans[i].append(int(pp))
    ans[i].append(i+1)
ans.sort(key=lambda x: (x[0],-x[1]))
for i in range(n):
    print((ans[i][2]))
# Original solution
def irekae(array2):
    return [array2[1],array2[0],array2[2]]

n=int(eval(input()))
l=[input().split() for i in range(n)]
"""
# print(l)
for i in range(len(l)):
    l[i].append(i+1)
    l[i][1]=int(l[i][1])
# print(l)
l.sort()
# print(l)
for i in range(len(l)):
    l[i]=irekae(l[i])
# print(l)
lsort=[]
while l!=[]:
    """
for i in range(len(l)):
    l[i].append(i+1)
    l[i][1]=int(l[i][1])
for i in range(len(l)):
    l[i]=irekae(l[i])
#print(l)
l.sort(reverse=True)
#print(l)
for i in range(len(l)):
    l[i]=irekae(l[i])
#print(l)

lx=sorted(l,key=lambda x: x[0])
#print(lx)
for i in range(len(lx)):
    print((lx[i][2]))

# Optimized solution
def irekae(array2):
    return [array2[1],array2[0],array2[2]]
n=int(eval(input()))
l=[input().split() for i in range(n)]
for i in range(len(l)):
    l[i].append(i+1)
    l[i][1]=int(l[i][1])
for i in range(len(l)):
    l[i]=irekae(l[i])
l.sort(reverse=True)
for i in range(len(l)):
    l[i]=irekae(l[i])
lx=sorted(l,key=lambda x: x[0])
for i in range(len(lx)):
    print((lx[i][2]))
# Original solution
#B
from operator import itemgetter
n = int(eval(input()))
sp=[]
for i in range(n):
    s,p=list(map(str,input().split()))
    sp.append([s, int(p), i + 1])
# print(sp)
#itemgetter:呼び出し可能なオブジェクトを返す　ex…f=itemgetter(2) f(a)>>a[2]
# sp = sorted(sp, key=lambda f: f[1], reverse=True)
# sp = sorted(sp, key=lambda f: f[0])
# print(sp)
sp.sort(key=itemgetter(1), reverse=True)
sp.sort(key=itemgetter(0))
# print(sp)
for i in range(n):
    print((sp[i][2]))

# Optimized solution
#B
n = int(eval(input()))

sp = [list(input().split()) for i in range(n)]
for i in range(n):
    sp[i].append(i + 1)
# print(sp)
sspp = sorted(sp, key=lambda x: int(x[1]), reverse=True)
sspp.sort(key=lambda x: x[0])
for i in range(n):
    print((sspp[i][2]))
# Original solution
n=int(eval(input()))
l=[]
for i in range(n):
    s,p=list(map(str,input().split()))
    l.append([s,int(p),i+1])
l=sorted(l,reverse=True,key=lambda x:x[1])
l = sorted(l, key=lambda x:x[0])
 
for i in range(n):
    print((l[i][-1]))

# Optimized solution
n=int(eval(input()))
l=[]
for i in range(n):
  s,p=input().split()
  p=int(p)*-1
  l.append([s,p,i+1])
l.sort()

for i in l:
  print((i[2]))
# Original solution
n=int(eval(input()))
rest=[input().split() for i in range(n)]
rest=[[rest[i][0],int(rest[i][1])] for i in range(n)]
for i in range(n):
  rest[i].append(i+1)

rest.sort(key=lambda i:i[0])
#print(rest)
cnt=0
for i in range(1,n):
  if rest[i-1][0]==rest[i][0]:
    continue
  else:
    res=rest[cnt:i]
    res.sort(key=lambda i:i[1],reverse=True)
    #print(res)
    for j in range(i-cnt):
      print((res[j][2]))
    cnt=i
    #print(str(cnt)+'がcntです')
res=rest[cnt:n]
#print(res)
res.sort(key=lambda i:i[1],reverse=True)
for i in range(n-cnt):
  print((res[i][2]))


# Optimized solution
n=int(input())
rest=[input().split()+[i+1] for i in range(n)]
rest.sort(key=lambda i:(i[0],-int(i[1])))
ans=[rest[i][2] for i in range(n)]
print(*ans,sep='\n')
# Original solution
n = int(eval(input()))
a= []
for i in range(n):
	city, score = input().split()
	score = int(score)
	a.append((city, score, i+1))
a.sort(key=lambda k : (k[0], -k[1]))
for i in range(n):
	print((a[i][2]))

# Optimized solution
n = eval(input())
n = int(n)
a= []
for i in range(n):
	city, score = input().split()
	score = int(score)
	a.append((city, score, i+1))
a.sort(key=lambda k : (k[0], -k[1]))
for i in range(n):
	print((a[i][2]))
# Original solution
from operator import itemgetter

N = int(input())
SP = []
d = {}
for i in range(1, N+1):
    s, p = input().split()
    SP.append([s, -int(p), i])
    d[int(p)] = i
# SP.sort(key= lambda x:x[0])
# SP.sort(key=lambda x:x[1])
SP.sort()
[print(i[2]) for i in SP]


# Optimized solution
N = int(eval(input()))
SP = []
for i in range(1, N + 1):
    s, p = input().split()
    SP.append((s, int(p), i))
sp = sorted(SP, key=lambda x: x[1], reverse=True)
for i in sorted(sp, key=lambda x: x[0]):
    print((i[2]))
# Original solution
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,p = LI()
    print(((a*3+p)//2))
    return

#B
def B():
    n = I()
    s = [None for i in range(n)]
    for i in range(n):
        l = input().split()
        s[i] = l+[i]
    s.sort(key = lambda x:(x[0],-int(x[1])))
    for i,a,b in s:
        print((b+1))
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()


# Optimized solution
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    g = []
    for i in range(n):
        s,p = input().split()
        p = int(p)
        g.append((s,-p,i+1))
    g.sort()
    for a,b,i in g:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()
# Original solution
n = int(eval(input()))

ss = []
ps = []
sps = []

for i in range(n):
    temp = input().split()
    ss.append(temp[0])
    ps.append(temp[1])
    sps.append(temp[0] + ' ' + temp[1] + ' ' + str(i))

def check(sps):
    city = sps[0].split()[0]
    score = int(sps[0].split()[1])
#    score = sps[0].split()[1]
    index = int(sps[0].split()[2])
    target = 0


    for i in range(1, len(sps)):
#        print(sps[i].split()[1])
#        print(score)

        if sps[i].split()[0] == city and score < int(sps[i].split()[1]):
#        if sps[i].split()[0] == city and score < sps[i].split()[1]:
            city = sps[i].split()[0]
            score = int(sps[i].split()[1])
            index = int(sps[i].split()[2])
            target = i
        elif sps[i].split()[0] < city:
            city = sps[i].split()[0]
            score = int(sps[i].split()[1])
            index = int(sps[i].split()[2])
            target = i

    # print(index + 1)
    # del sps[i]
#    return index
    return target, index

for i in range(n):
    target, index = check(sps)
    print((index + 1))
    del sps[target]


# Optimized solution
n = int(eval(input()))
sps = []

for i in range(n):
    line = input().split()
    sps.append([line[0], -(int(line[1])), i + 1])

sps.sort()

for i in range(n):
    print((sps[i][2]))
# Original solution
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(eval(input()))
SP = [[x for x in input().split()] for _ in range(n)]
ans_list = defaultdict(list)
for i, sp in enumerate(SP):
    ans_list[sp[1]] = i

li = sorted(SP, key=lambda x: -int(x[1]))
li = sorted(li, key=lambda x: x[0])
#print(li)
#print(ans_list)
for x in li:
    print((ans_list[x[1]]+1))



# Optimized solution
N = int(eval(input()))
SP = []
for i in range(N):
  s, p = list(input().split())
  SP.append([s, int(p), i+1])
SP.sort(key=lambda SP:(SP[0], -SP[1]))
for x in SP:
  print((x[2]))
# Original solution
n=int(eval(input()))
sp=[]
for i in range(n):
  x,y=input().split()
  sp.append([x,int(y),i+1])
  sp.sort(key=lambda x:(x[0],-x[1]))
for i in range(n):
  print((sp[i][2]))


# Optimized solution
n = int(eval(input()))

l = []
for i in range(n):
  x,y = list(map(str,input().split()))
  l.append((x,y, i))


L = []

for i in range(n):
  L.append((l[i][0], int(l[i][1]), l[i][2]))

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


for i in range(n):
  print((L[i][2] + 1))
# Original solution
from operator import itemgetter

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

L = sorted(L, key=itemgetter(1), reverse=True)
L = sorted(L, key=itemgetter(0))

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


# Optimized solution
N = int(eval(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 l in L:
    print((l[2]))
# Original solution
n = int(eval(input()))
s, p = [], []
for i in range(n):
  inp = input().split()
  s.append(inp[0])
  p.append(int(inp[1]))

ans_list = list(i for i in range(1, n + 1))
for i in range(n):
  index = i
  for j in range(i, n):
    if s[index] > s[j] or (s[index] == s[j] and p[index] < p[j]):
      index = j
  s[i], s[index] = s[index], s[i]
  p[i], p[index] = p[index], p[i]
  ans_list[i], ans_list[index] = ans_list[index], ans_list[i]

for i in ans_list:
  print(i)

# Optimized solution
n = int(eval(input()))
sp = []
for i in range(n):
  inp = input().split()
  sp.append((inp[0], int(inp[1]), i + 1))

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

for i in sp:
  print((i[2]))
# Original solution
N = int(eval(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]))

# Optimized solution
N = int(eval(input()))
A = [list(input().split()) for _ in range(N)]
A = [(A[i][0],int(A[i][1]),i+1) for i in range(N)]
A = sorted(A,key=lambda x:x[1],reverse=True)
A = sorted(A,key=lambda x:x[0])
for i in range(N):
    print((A[i][2]))
# Original solution
N = int(eval(input()))
data = []

for i in range(N):
    name, point = input().split()
    data.append((name, int(point), i))

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


# Optimized solution
N = int(eval(input()))
data = []

for i in range(N):
    name, point = input().split()
    data.append((name, int(point), i))

data.sort(key=lambda x:-x[1])
data.sort(key=lambda x:x[0])
for d in data:
    print((d[2] + 1))