#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector> P(h, vector(w)); vector> S(h, vector(w)); for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ cin >> P[y][x]; P[y][x] /= 100; } } for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ cin >> S[y][x]; } } vector pre(1 << w), dp(1 << w); pre[0] = 1; queue que; double ans = 0; for(int y = 0; y < h; y++){ //S1:現在の列が知っているか否か //S0:前の列が手を上げたか否か auto f = [&](int S0, int S1, int visited, int x){ int tmp = (S0 >> x & 1) + (visited >> x + 1 & 1) + (x ? visited >> x - 1 & 1 : 0); if(S1 >> x & 1) tmp += 4 - S[y][x]; return (tmp >= 4); }; for(int S1 = 0; S1 < (1 << w); S1++){ double prob = 1; for(int x = 0; x < w; x++){ if(S1 >> x & 1) prob *= P[y][x]; else prob *= 1 - P[y][x]; } for(int S0 = 0; S0 < (1 << w); S0++){ if(pre[S0] == 0) continue; int visited = 0; for(int x = 0; x < w; x++){ if((S0 >> x & 1) + (S1 >> x & 1 ? 4 - S[y][x] : 0) >= 4){ visited |= 1 << x; que.emplace(x); } } while(!que.empty()){ int x = que.front(); que.pop(); if(x + 1 < w && (~visited >> x + 1 & 1) && f(S0, S1, visited, x + 1)){ visited |= 1 << x + 1; que.emplace(x + 1); } if(x >= 1 && (~visited >> x - 1 & 1) && f(S0, S1, visited, x - 1)){ visited |= 1 << x - 1; que.emplace(x - 1); } } dp[visited] += prob * pre[S0]; } } for(int bit = 0; bit < (1 << w); bit++){ ans += __builtin_popcount(bit) * dp[bit]; pre[bit] = dp[bit]; dp[bit] = 0; } } cout << fixed << setprecision(15) << ans << '\n'; }