import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] marks = new String[5]; int[] points = new int[5]; HashMap map = new HashMap<>(); for (int i = 0; i < 5; i++) { marks[i] = sc.next(); map.put(marks[i], i); points[i] = sc.nextInt(); } int a = sc.nextInt(); int[] countsA = new int[5]; for (int i = 0; i < a; i++) { countsA[map.get(sc.next())]++; } int b = sc.nextInt(); int[] countsB = new int[5]; for (int i = 0; i < b; i++) { countsB[map.get(sc.next())]++; } int c = sc.nextInt(); int[] countsC = new int[5]; for (int i = 0; i < c; i++) { countsC[map.get(sc.next())]++; } StringBuilder sb = new StringBuilder(); double ans = 0; for (int i = 0; i < 5; i++) { ans += countsA[i] / (double)a * countsB[i] / (double) b * countsC[i] / (double)c * points[i] * 5; sb.append(5L * countsA[i] * countsB[i] * countsC[i]).append("\n"); } System.out.println(ans); System.out.print(sb); } }