#include #define pq priority_queue #define P pair #define P2 pair #define P3 pair using namespace std; typedef long long ll; typedef long double ld; constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;} constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;} constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0}; constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;} template struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i fact; constexpr Prime<10> prime; constexpr int comb(int a, int b){long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b];return pos * pot % MOD * por % MOD;} constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1}; constexpr int sqrtN = 512, logN = 32; constexpr ld PI = abs(acos(-1)); constexpr ll LINF=1e18; int main(){ map mp2; ll a[5]; for(int i = 0; i < 5; i++){ string s; cin >> s >> a[i]; mp2[s] = i; } ld t = 1; ll li[3][5] = {}; for(int S = 0; S < 3; S++){ int n; cin >> n; t *= n; for(int i = 0; i < n; i++){ string s; cin >> s; li[S][mp2[s]]++; } } ll ans[5] = {}; for(int i = 0; i < 5; i++){ ll ret = 5; for(int j = 0; j < 3; j++){ ret *= li[j][i]; } ans[i] = ret; } ld s = 0; for(int i = 0; i < 5; i++) s += ans[i] * a[i]; cout << fixed << setprecision(10); cout << s / t << endl; for(int i = 0; i < 5; i++) cout << ans[i] << endl; return 0; }