role_list = [] role_return = {} role_hits = {} pattern = 1 for i in range(5): s = input().split() role_list.append(s[0]) role_return[s[0]] = int(s[1]) role_hits[s[0]] = 1 for i in range(3): r_list = {} n = int(input()) pattern *= n for j in range(n): s = input() r_list[s]=r_list.get(s,0)+1 for j in role_list: role_hits[j] *= r_list.get(j,0) coins = 0 for i in role_list: coins += role_return[i]*role_hits[i]*5 print(coins/pattern) for i in role_list: print(role_hits[i]*5)