#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); pre[0] = 1; auto f = [&](int S0, int S1, int x){ int cnt = 0; cnt += (S0 >> x) & 1; if(x) cnt += (S1 >> x - 1) & 1; cnt += (S1 >> x + 1) & 1; return cnt; }; double ans = 0; for(int y = 0; y < h; y++){ //前の列手を挙げている人がS0でS1に遷移する確率 vector dp(1 << w); for(int S0 = 0; S0 < (1 << w); S0++){ if(pre[S0] == 0) continue; for(int S1 = 0; S1 < (1 << w); S1++){ double p = pre[S0], p0, p1; for(int x = 0; x < w; x++){ p0 = p1 = 0; int c = f(S0, S1, x); if(S1 >> x & 1){ if(4 - S[y][x] + c >= 4) p0 = P[y][x] * p; if(c >= 4) p1 = (1 - P[y][x]) * p; }else{ if(4 - S[y][x] + c < 4) p0 = P[y][x] * p; if(c < 4) p1 = (1 - P[y][x]) * p; } p = p0 + p1; } dp[S1] += p; ans += p * __builtin_popcount(S1); } } swap(pre, dp); } cout << fixed << setprecision(15) << ans << '\n'; }