#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int bitcnt(int n){ int res = 0; while(n){ if(n&1) ++res; n>>=1; } return res; } const double EPS = 1e-14; int R, C; double P[11][11], prob[12][1 << 11]; int S[11][11], nextHands[1 << 22], dontKnow[1 << 11]; void solve(){ rep(mask, 1 << C) rep(i, C) if((mask >> i & 1) == 0) dontKnow[mask] |= (3 << (2 * i)); rep(mask, 1 << (C * 2)){ queue Q; vi state(C); rep(x, C){ state[x] = mask >> (2 * x) & 3; if(state[x] == 0)Q.push(x + 1), Q.push(x - 1); } while(sz(Q)){ int x = Q.front(); Q.pop(); if(x < 0 || x >= C || state[x] <= 0)continue; if(--state[x] == 0)Q.push(x - 1), Q.push(x + 1); } rep(x, C)if(state[x] <= 0)nextHands[mask] |= 1 << x; } double ans = 0.0; prob[0][0] = 1; rep(y, R){ vector rowProb(1 << C, 1.0); rep(mask, 1 << C)rep(x, C){ if(mask >> x & 1)rowProb[mask] *= P[y][x]; else rowProb[mask] *= 1 - P[y][x]; } rep(upMask, 1 << C){ int needMask = 0; rep(x, C){ int need = 4 - (upMask >> x & 1) - (4 - S[y][x]); smin(need, 3); smax(need, 0); needMask |= need << (x * 2); } rep(knowMask, 1 << C){ int nextUpMask = nextHands[needMask | dontKnow[knowMask]]; prob[y + 1][nextUpMask] += prob[y][upMask] * rowProb[knowMask]; } } rep(mask, 1 << C)ans += bitcnt(mask)*prob[y + 1][mask]; } printf("%0.20f\n", ans); } int main(){ while(cin >> R >> C){ rep(i, R)rep(j, C){ cin >> P[i][j]; P[i][j] *= 0.01; } rep(i, R)rep(j, C)cin >> S[i][j]; rep(i, R + 1)rep(j, 1 << C)prob[i][j] = 0; MEM(nextHands, 0); MEM(dontKnow, 0); solve(); } }