from collections import Counter lis = [] for _ in range(5): l = list(map(str,input().split())) lis.append(l) n1 = int(input()) r1 = [] for _ in range(n1): r1.append(input()) r1 = Counter(r1) n2 = int(input()) r2 = [] for _ in range(n2): r2.append(input()) r2 = Counter(r2) n3 = int(input()) r3 = [] for _ in range(n3): r3.append(input()) r3 = Counter(r3) each_cnt = [] for i in range(5): ans = 5*r1[lis[i][0]]*r2[lis[i][0]]*r3[lis[i][0]] each_cnt.append(ans) ex = 0 for i in range(5): ex += each_cnt[i] * int(lis[i][1]) print(ex / (n1 * n2 * n3)) for i in range(5): print(each_cnt[i])