d = {} for _ in range(5): a,b = input().split() d[a] = int(b) num = {k:5 for k in d} tot = 1 for _ in range(3): n = int(input()) tot *= n dd = {k:0 for k in d} for __ in range(n): dd[input()] += 1 for k,v in dd.items(): num[k] *= v ans = 0 for k,v in num.items(): ans += d[k]*v print(ans/tot) for k,v in num.items(): print(v)