#include "bits/stdc++.h" using namespace std; #define DEBUG(x) cout<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() const int inf = 1000000001; const ll INF = 2e18; const ll MOD = 1000000007; const ll mod = 1000000009; const double pi = 3.14159265358979323846; #define Sp(p) cout< a) { swap(a, b); } ll r = a%b; while (r != 0) { a = b; b = r; r = a%b; } return b; } signed main() { vs str(5); vi coin(5); map mp; rep(i, 5) { cin >> str[i] >> coin[i]; mp[str[i]] = i; } vi n(3); vector a(3); vii num(3, vi(5)); rep(i, 3) { cin >> n[i]; rep(j, n[i]) { string s; cin >> s; a[i].push_back(s); num[i][mp[s]]++; } } vl u(5); rep(i, 5) { u[i] = 5 * num[0][i] * num[1][i] * num[2][i]; } ll sum = n[0] * n[1] * n[2]; cout << sum << endl; ll score = 0; rep(i, 5) { score += u[i] * coin[i]; } cout << (double)score / sum << endl; rep(i, 5) { cout << u[i] << endl; } }