#include using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define loop for(;;) #define trace(var) cerr<<">>> "<<#var<<" = "<; template inline ostream& operator<<(ostream&os, pair p) { return os << '(' << p.first << ", " << p.second << ')'; } template inline ostream& operator<<(ostream&os, tuple t) { return os << '(' << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << ')'; } template inline ostream& operator<<(ostream&os, set v) { os << "(set"; for (T item: v) os << ' ' << item; os << ")"; return os; } template inline ostream& operator<<(ostream&os, vector v) { if (v.size() == 0) { return os << "(empty)"; } os << v[0]; for (int i=1, len=v.size(); i inline istream& operator>>(istream&is, vector&v) { rep (i, v.size()) is >> v[i]; return is; } using vi = vector; using vvi = vector; using vd = vector; using vvd = vector; using vb = vector; inline vi bit_pattern(int I, int w) { vi r; rep (i, w) r.push_back((I & (1 << i)) ? 1 : 0); return r; } int main() { cerr << fixed << setprecision(5); int h, w; cin >> h >> w; vvi p(h+1, vi(w, 0)); vvi s(h+1, vi(w, 0)); rep (i, h) rep (j, w) cin >> p[i+1][j]; rep (i, h) rep (j, w) cin >> s[i+1][j]; rep (j, w) { p[0][j] = 0; s[0][j] = 4; } vvd Pr(h+1, vd(w, 0)); for (int i = 1; i <= h; ++i) { rep (I, (1< s; rep (j, w) if (pt[j] >= 4) { s.push(j-1); s.push(j+1); } while (not s.empty()) { int j = s.top(); s.pop(); if (j < 0 or j>=w) continue; pt[j]++; if (pt[j] == 4) { s.push(j-1); s.push(j+1); } } double pr = 1.0; // of I and J rep (j, w) { pr *= (raising[j] ? Pr[i-1][j] : (1.0 - Pr[i-1][j])) * (is_known[j] ? p[i][j] : (100-p[i][j])) / 100.0; } rep (j, w) if (pt[j] >= 4) Pr[i][j] += pr; } } } //rep (i, h+1) { rep (j, w) cerr << Pr[i][j] << ' '; cerr << endl; } double ans = 0.0; rep (i, h+1) rep (j, w) ans += Pr[i][j]; cout << ans << endl; return 0; }