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