#include using namespace std; using ll = long long; constexpr char newl = '\n'; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); map coins; map ids; for (int i = 0; i < 5; i++) { string s; int c; cin >> s >> c; coins[s] = c; ids[s] = i; } array ns; array< vector, 3> reels; for (int i = 0; i < 3; i++) { cin >> ns[i]; reels[i].resize(ns[i]); for (int j = 0; j < ns[i]; j++) { cin >> reels[i][j]; } } map cnt1, cnt2; for (int i = 0; i < ns[1]; i++) { ++cnt1[reels[1][i]]; } for (int i = 0; i < ns[2]; i++) { ++cnt2[reels[2][i]]; } array ans{}; for (int i = 0; i < ns[0]; i++) { ans[ids[reels[0][i]]] += cnt1[reels[0][i]] * cnt2[reels[0][i]] * 5; } ll sum = 0; for (auto& p : coins) { sum += ans[ids[p.first]] * p.second; } long double a = sum; a /= (ll)ns[0] * ns[1] * ns[2]; cout << fixed << setprecision(15) << a << newl; for (int i = 0; i < 5; i++) { cout << ans[i] << newl; } return 0; }