#include #include #include using namespace std; int main(){ string slot[5]; long coin[5]; for(int i = 0; i < 5; i++){ cin >> slot[i] >> coin[i]; } map reel[3]; long all_pattern = 1; for(int i = 0; i < 3; i++){ long n; cin >> n; all_pattern *= n; for(int j = 0; j < n; j++){ string reel_slot; cin >> reel_slot; reel[i][reel_slot]++; } } long slot_patterns[5]; long money_sum = 0; for(int i = 0; i < 5; i++){ slot_patterns[i] = 1; for(int j = 0; j < 3; j++){ slot_patterns[i] *= reel[j][slot[i]]; } money_sum += slot_patterns[i] * coin[i]; } cout << fixed << money_sum / double(all_pattern) * 5 << endl; for(int i = 0; i < 5; i++){ cout << slot_patterns[i] * 5 << endl; } }