import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Map map = new HashMap(); String[]key = new String[5]; for(int i = 0; i < 5; i++) { String s = scan.next(); long t = scan.nextInt(); map.put(s, t); key[i] = s; } int n1 = scan.nextInt(); String[]A = new String[n1]; Map mapA = new HashMap(); for(int i = 0; i < n1; i++) { A[i] = scan.next(); mapA.merge(A[i], 1L, (val1, val2) -> val1 + val2); } int n2 = scan.nextInt(); Map mapB = new HashMap(); String[]B = new String[n2]; for(int i = 0; i < n2; i++) { B[i] = scan.next(); mapB.merge(B[i], 1L, (val1, val2) -> val1 + val2); } int n3 = scan.nextInt(); String[]C = new String[n3]; Map mapC = new HashMap(); for(int i = 0; i < n3; i++) { C[i] = scan.next(); mapC.merge(C[i], 1L, (val1, val2) -> val1 + val2); } scan.close(); long sum = 0; long[]U = new long[5]; for(int i = 0; i < 5; i++) { if(mapA.containsKey(key[i]) && mapB.containsKey(key[i]) && mapC.containsKey(key[i])) { sum += 5 * map.get(key[i]) * mapA.get(key[i]) * mapB.get(key[i]) * mapC.get(key[i]); U[i] = 5 * mapA.get(key[i]) * mapB.get(key[i]) * mapC.get(key[i]); } } double E = (double) sum / (n1 * n2 * n3); System.out.println(E); for(long i : U) { System.out.println(i); } } }