N = int(input())
rev = {}
ind_dic = {}
for i in range(1, N+1):
    k, v = input().split()
    
    if k in rev:
        rev[k].append(v)
    else:
        rev[k] = [v]
    ind_dic[v] = i

for v in rev.values():
    for i in range(len(v)):
        v[i] = int(v[i])
    v.sort(reverse=True)

key_lst = []
for k in rev.keys():
    key_lst.append(k)
key_lst.sort()

new_dic = {}
for k in key_lst:
    new_dic[k] = rev[k]

for k in new_dic.keys():
    for i in range(len(new_dic[k])):
        print(ind_dic[str(new_dic[k][i])]) N = int(input()) N int(input()) int input() input rev = {} rev {} ind_dic = {} ind_dic {} for i in range(1, N+1):
    k, v = input().split()
    
    if k in rev:
        rev[k].append(v)
    else:
        rev[k] = [v]
    ind_dic[v] = i i range(1, N+1) range 1 N+1 N 1 k, v = input().split() k input().split() ().split () input split v if k in rev:
        rev[k].append(v)
    else:
        rev[k] = [v]
     k in rev k rev rev[k].append(v) [k].append [k] rev k append v rev[k] = [v] rev[k] rev k [v] v ind_dic[v] = i ind_dic[v] ind_dic v i for v in rev.values():
    for i in range(len(v)):
        v[i] = int(v[i])
    v.sort(reverse=True) v rev.values() rev.values rev values for i in range(len(v)):
        v[i] = int(v[i])
     i range(len(v)) range len(v) len v v[i] = int(v[i]) v[i] v i int(v[i]) int v[i] v i v.sort(reverse=True) v.sort v sort reverse=True reverse True key_lst = [] key_lst [] for k in rev.keys():
    key_lst.append(k) k rev.keys() rev.keys rev keys key_lst.append(k) key_lst.append key_lst append k key_lst.sort() key_lst.sort key_lst sort new_dic = {} new_dic {} for k in key_lst:
    new_dic[k] = rev[k] k key_lst new_dic[k] = rev[k] new_dic[k] new_dic k rev[k] rev k for k in new_dic.keys():
    for i in range(len(new_dic[k])):
        print(ind_dic[str(new_dic[k][i])]) k new_dic.keys() new_dic.keys new_dic keys for i in range(len(new_dic[k])):
        print(ind_dic[str(new_dic[k][i])]) i range(len(new_dic[k])) range len(new_dic[k]) len new_dic[k] new_dic k print(ind_dic[str(new_dic[k][i])]) print ind_dic[str(new_dic[k][i])] ind_dic str(new_dic[k][i]) str new_dic[k][i] [k] new_dic k i new_dic = {} {} new_dic k, v = input().split() input().split() k ind_dic = {} {} ind_dic rev = {} {} rev N = int(input()) int(input()) N key_lst = [] [] key_lst v = input().split() input().split() v
N = int(input())
rev = {}
ind_dic = {}
for i in range(1, N+1):
    k, v = input().split()
    
    if k in rev:
        rev[k].append(v)
    else:
        rev[k] = [v]
    ind_dic[v] = i

for v in rev.values():
    for i in range(len(v)):
        v[i] = int(v[i])
    v.sort(reverse=True)

key_lst = []
for k in rev.keys():
    key_lst.append(k)
key_lst.sort()

new_dic = {}
for k in key_lst:
    new_dic[k] = rev[k]

for k in new_dic.keys():
    for i in range(len(new_dic[k])):
        print(ind_dic[str(new_dic[k][i])])