#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { map conv; vector coin(5); REP(i, 5) { string S; cin >> S >> coin[i]; conv[S] = i; } int N[3]; vector A[3]; REP(i, 3) { scanf("%d", &N[i]); A[i].resize(N[i]); REP(j, N[i]) { string S; cin >> S; A[i][j] = conv[S]; } } int cnt[3][125] {}; REP(i, 3) { REP(j, N[i]) { const int p1 = A[i][j], p2 = A[i][(j + 1) % N[i]], p3 = A[i][(j + 2) % N[i]]; ++cnt[i][p1 * 25 + p2 * 5 + p3]; } } ll sum = 0, ans[5] {}; REP(i, 125) REP(j, 125) REP(k, 125) { const int a[3][3] = { { i/25, j/25, k/25 }, { i/5%5, j/5%5, k%5 }, { i%5, j%5, k%5 }, }; ll p = (ll)cnt[0][i] * cnt[1][j] * cnt[2][k]; REP(l, 3) if (a[l][0] == a[l][1] && a[l][1] == a[l][2]) { ans[a[l][0]] += p; sum += coin[a[l][0]] * p; } int c = a[0][0] == a[1][1] && a[1][1] == a[2][2]; c += a[2][0] == a[1][1] && a[1][1] == a[0][2]; ans[a[1][1]] += c * p; sum += c * coin[a[1][1]] * p; } printf("%.16f\n", (double)sum / ((ll)N[0] * N[1] * N[2])); REP(i, 5) cout << ans[i] << endl; }