/* -*- coding: utf-8 -*- * * 662.cc: No.662 スロットマシーン - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int N = 5; const int M = 3; /* typedef */ typedef long long ll; typedef long double ld; typedef map msi; /* global variables */ string ss[N]; int cs[N], ds[N][M]; ll es[N]; msi smap; /* subroutines */ /* main */ int main() { for (int i = 0; i < N; i++) { cin >> ss[i] >> cs[i]; smap[ss[i]] = i; } ll p = 1; for (int i = 0; i < M; i++) { int ni; cin >> ni; p *= ni; for (int j = 0; j < ni; j++) { string sj; cin >> sj; ds[smap[sj]][i]++; } } ll sum = 0; for (int i = 0; i < N; i++) { es[i] = 5; for (int j = 0; j < M; j++) es[i] *= ds[i][j]; sum += es[i] * cs[i]; } printf("%.6Lf\n", (ld)sum / p); for (int i = 0; i < N; i++) printf("%lld\n", es[i]); return 0; }