import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.HashMap; import java.util.ArrayList; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); No662 solver = new No662(); solver.solve(1, in, out); out.close(); } static class No662 { public void solve(int testNumber, Scanner in, PrintWriter out) { Map map = new HashMap<>(); Map[] cnt = new Map[3]; String[] strs = new String[5]; for (int i = 0; i < 3; i++) { cnt[i] = new HashMap<>(); } for (int i = 0; i < 5; i++) { strs[i] = in.next(); map.put(strs[i], in.nextInt()); } long sum = 1; for (int i = 0; i < 3; i++) { int n = in.nextInt(); sum *= n; for (int j = 0; j < n; j++) { String s = in.next(); if (cnt[i].containsKey(s)) { cnt[i].put(s, cnt[i].get(s) + 1); } else { cnt[i].put(s, 1); } } } List u = new ArrayList<>(); { // mode long coins = 0; for (String s : strs) { long val = 5; for (int i = 0; i < 3; i++) { if (cnt[i].containsKey(s)) val *= cnt[i].get(s); else val = 0; } u.add(val); coins += val * map.get(s); } out.println((double) coins / sum); } { for (long v : u) { out.println(v); } } } } }