dic = {} for i in range(5): a, b = input().split() dic[a] = int(b) dict = {} cnt = 1 for i in range(3): n = int(input()) cnt *= n ad = {} for j in range(n): a = input() if a not in ad: ad[a] = 1 else: ad[a] += 1 for k, v in ad.items(): if k not in dict: dict[k] = [v] else: dict[k].append(v) new_dict = {} for k, v in dict.items(): if len(v) == 3: a = 1 for i in range(3): a *= v[i] a *= 5 new_dict[k] = a else: new_dict[k] = 0 total = 0 for k, v in dic.items(): if k in new_dict: dic[k] = new_dict[k] * v else: dic[k] = 0 total += dic[k] print(total / cnt) for k in dic.keys(): if k in new_dict: print(new_dict[k]) else: print(0)