import java.io.*; import java.util.*; public class Main_yukicoder662 { private static Scanner sc; private static Printer pr; private static void solve() { String[] str = new String[5]; int[] coin = new int[5]; for (int i = 0; i < 5; i++) { str[i] = sc.next(); coin[i] = sc.nextInt(); } int n1 = sc.nextInt(); Map hm1 = new HashMap<>(); for (int i = 0; i < n1; i++) { String a = sc.next(); if (hm1.containsKey(a)) { hm1.put(a, hm1.get(a) + 1); } else { hm1.put(a, 1); } } int n2 = sc.nextInt(); Map hm2 = new HashMap<>(); for (int i = 0; i < n2; i++) { String a = sc.next(); if (hm2.containsKey(a)) { hm2.put(a, hm2.get(a) + 1); } else { hm2.put(a, 1); } } int n3 = sc.nextInt(); Map hm3 = new HashMap<>(); for (int i = 0; i < n3; i++) { String a = sc.next(); if (hm3.containsKey(a)) { hm3.put(a, hm3.get(a) + 1); } else { hm3.put(a, 1); } } long ans = 0; long[] cnt = new long[5]; for (int i = 0; i < 5; i++) { Integer tmp1 = hm1.get(str[i]); Integer tmp2 = hm2.get(str[i]); Integer tmp3 = hm3.get(str[i]); if (tmp1 == null || tmp2 == null || tmp3 == null) { continue; } cnt[i] += 5L * tmp1 * tmp2 * tmp3; ans += cnt[i] * coin[i]; } pr.printf("%.2f\n", (double)ans / n1 / n2 / n3); for (int i = 0; i < 5; i++) { pr.println(cnt[i]); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }