#!coding:utf-8 ref=[chr(i) for i in range(65,65+26)] N=int(raw_input()) L=map(int,raw_input().split()) T=int(raw_input()) Timing=[1]*N kekka={} for i in range(T): NP=raw_input().split() Name=NP[0] Prob_No=ref.index(NP[1]) Point=int(50*L[Prob_No]+50*L[Prob_No]/(0.8+0.2*Timing[Prob_No])) Timing[Prob_No]=Timing[Prob_No]+1 if Name in kekka: kekka[Name][1][Prob_No]=Point kekka[Name][2]=T-i else: kekka[Name]=[0,[0]*N,0] kekka[Name][1][Prob_No]=Point kekka[Name][2]=T-i l_kekka=[] for k in kekka.keys(): kekka[k][0]=sum(kekka[k][1]) l_kekka.append([k,kekka[k]]) l_kekka=sorted(l_kekka, key=lambda x:(x[1][0],x[1][2]), reverse=True) itr=1 for i in l_kekka: i[1][1]=map(str,i[1][1]) st=str(itr)+" "+i[0]+" "+str(" ".join(i[1][1]))+ " "+str(i[1][0]) print st itr=itr+1