def main(): pictures = [None] * 5 coins = [None] * 5 for i in range(5): pictures[i], coins[i] = input().split() coins[i] = int(coins[i]) n1 = int(input()) A = [None] * n1 for i in range(n1): A[i] = input() n2 = int(input()) B = [None] * n2 for j in range(n2): B[j] = input() n3 = int(input()) C = [None] * n3 for k in range(n3): C[k] = input() a = 0 U = [0] * 5 for i, picture in enumerate(pictures): A_cnt = A.count(picture) B_cnt = B.count(picture) C_cnt = C.count(picture) U[i] = (A_cnt * B_cnt * C_cnt) * 5 a += U[i] * coins[i] print(a / (n1 * n2 * n3)) for i in range(5): print(U[i]) if __name__ == "__main__": main()