#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>H>>W; FOR(y,H) FOR(x,W) cin>>r, P[y][x] = r/100.0; FOR(y,H) FOR(x,W) cin>>S[y][x]; double ret=0; dp[0][0]=1; FOR(y,H) { for(int cur=0;cur<1<1e-12) { int hand2=hand; FOR(j,2) FOR(i,W) { x=(j)?i:(W-1-i); if(cur&(1<=4) hand2 |= 1<<(x+1); } } hand2 >>=1; ret += pat*dp[y][up]*__builtin_popcount(hand2); dp[y+1][hand2] += pat*dp[y][up]; } } } _P("%.12lf\n",ret); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }