#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int main() { string S[5]; int C[5]; for ( int i = 0; i < 5; i++ ) { cin >> S[i] >> C[i]; } int N[3]; vector< vector > A( 3, vector(5,0) ); for ( int i = 0; i < 3; i++ ) { cin >> N[i]; for ( int j = 0; j < N[i]; j++ ) { string s; cin >> s; for ( int k = 0; k < 5; k++ ) { if ( S[k] == s ) { A[i][k]++; } } } } long long sum = 0; for ( int i = 0; i < 5; i++ ) { long long a = 1; for ( int j = 0; j < 3; j++ ) { a *= A[j][i]; } sum += a*5*C[i]; } long long n = 1; for ( int i = 0; i < 3; i++ ) { n *= N[i]; } printf( "%.5f\n", static_cast(sum) / static_cast(n) ); return 0; }