#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template static void amin(T &x, U y) { if (y < x) x = y; } template static void amax(T &x, U y) { if (x < y) x = y; } int main() { const int N = 5, M = 3; vector names; vector coins; rep(k, N) { string str; int coin; cin >> str >> coin; names.push_back(str); coins.push_back(coin); } vector> counts(M); vector ns(M); rep(k, M) { int n; scanf("%d", &n); ns[k] = n; rep(i, n) { string str; cin >> str; ++ counts[k][str]; } } vector num; ll total = 0; rep(i, N) { ll prod = 1; rep(j, M) prod *= counts[j][names[i]]; prod *= 5; num.push_back(prod); total += prod * coins[i]; } double expected = (double)total; rep(k, M) expected /= ns[k]; printf("%.10f\n", expected); rep(i, N) printf("%lld\n", num[i]); return 0; }