D = {} for _ in range(5): A, B = input().split() D[A] = int(B) NUM = {K:5 for K in D} T = 1 for _ in range(3): N = int(input()) T *= N DD = {K:0 for K in D} for __ in range(N): DD[input()] += 1 for K, V in DD.items(): NUM[K] *= V RE = 0 for K, V in NUM.items(): RE += D[K] * V print(RE / T) for K, V in NUM.items(): print(V)