#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int main() { ios_base::sync_with_stdio(0); cin.tie(0); map idx; vector coin; REP (i, 5) { int x; string s; cin >> s >> x; idx[s] = idx.size(); coin.push_back(x); } vector > vs; REP (i, 3) { int n; cin >> n; vector v(n); REP (i, n) { string s; cin >> s; v[i] = idx[s]; } vs.push_back(v); } vector ret(5); REP (i, 5) { ret[i] = 5; REP (j, 3) ret[i] *= count(vs[j].begin(), vs[j].end(), i); } double ans = 0.0; REP (i, 5) ans += 1.0 * coin[i] * ret[i]; REP (i, 3) ans /= vs[i].size(); cout << fixed << setprecision(5) << ans << endl; REP (i, 5) cout << ret[i] << endl; return 0; }