#include #include #include #include #include using namespace std; int main(){ cout << fixed << setprecision(10); map mp; vector c(5); for (int i = 0; i < 5; i++){ string s; cin >> s >> c[i]; mp[s] = i; } vector U(5, 5); long long m = 1; for (int i = 0; i < 3; i++){ int n; cin >> n; m *= n; vector cnt(5, 0); for (int j = 0; j < n; j++){ string s; cin >> s; cnt[mp[s]]++; } for (int j = 0; j < 5; j++){ U[j] *= cnt[j]; } } double E = 0; for (int j = 0; j < 5; j++){ E += c[j] * U[j]; } E /= m; cout << E << endl; cout << fixed << setprecision(0); for (int i = 0; i < 5; i++){ cout << U[i] << endl; } }