#include using namespace std; #define modulo 998244353 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 1000000005 vector n0(int&); vector n1(int&); vector n2(int&); vector n3(int&); int N; double P,Q,R; string S; vector OR(vector a,vector b){ vector ans(2,0.0); a[0] *= b[0]; a[1] = 1.0-a[0]; ans[0] = (1.0-R)*a[0] + R*a[1]; ans[1] = 1.0-ans[0]; return ans; } vector AND(vector a,vector b){ vector ans(2,0.0); a[1] *= b[1]; a[0] = 1.0-a[1]; ans[0] = (1.0-R)*a[0] + R*a[1]; ans[1] = 1.0-ans[0]; return ans; } vector RANDOM(vector a,vector b){ double t = a[1]*b[1]; vector ans(2,0.0); ans[1] = P*t + Q*(1.0-t); ans[0] = 1.0-ans[1]; return ans; } vector n0(int &i){ vector x = n1(i); while(true){ if(i==S.size())return x; if(S[i]!='o')return x; i++; vector y = n1(i); x = OR(x,y); } } vector n1(int &i){ vector x = n2(i); while(true){ if(i==S.size())return x; if(S[i]!='a')return x; i++; vector y = n2(i); x = AND(x,y); } } vector n2(int &i){ vector x; if(S[i]=='('){ i++; x = n0(i); i++; } else{ x = n3(i); } return x; } vector n3(int &i){ vector x(2,0.0); if(S[i]=='Y'){ x[1] = 1.0; i++; } else if(S[i]=='N'){ x[0] = 1.0; i++; } else{ i+=2; vector y = n0(i); vector z = n0(i); x = RANDOM(y,z); i++; } return x; } int main(){ cin>>N>>P>>Q>>R; cin>>S; { string T = ""; for(int i=0;i ans = n0(j); cout<