def calcscore(lv, tm): from math import floor return int(floor(50 * lv + 50.0 * lv / (0.8 + 0.2 * tm))) n = int(input()) level = {} acninzu = {} for i, lv in enumerate(map(int, input().split())): problem = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[i:i+1] level[problem] = lv acninzu[problem] = 0 kakujinscore = {} t = int(input()) for i in range(t): name, problem = input().split() acninzu[problem] += 1 thisscore = calcscore(level[problem], acninzu[problem]) if name in kakujinscore: scores, _ = kakujinscore[name] scores[problem] = thisscore kakujinscore[name] = scores, i else: scores = {} scores[problem] = thisscore kakujinscore[name] = scores, i def sortfunc(name): scores, time = kakujinscore[name] totalscore = sum(scores.values()) return totalscore * t + (t - time - 1) ranking = sorted(kakujinscore, key=sortfunc, reverse=True) for i, name in enumerate(ranking): scores, _ = kakujinscore[name] scorelist = [] for j, problem in enumerate('ABCDEFGHIJKLMNOPQRSTUVWXYZ'): if j >= n: break if problem in scores: scorelist.append(scores[problem]) else: scorelist.append(0) totalscore = sum(scores.values()) print(i + 1, name, *scorelist, totalscore)