r, c = map(int, raw_input().split()) raw_input() p = [map(int, raw_input().split()) + [0] for i in xrange(r)] + [0]*(c+1) raw_input() s = [map(int, raw_input().split()) + [4] for i in xrange(r)] + [4]*(c+1) def f(a, b, c): r = 1.0 r *= dpp[j] if a else 1.0-dpp[j] r *= dpi[j-1] if b else 1.0-dpi[j-1] r *= dpi[j+1] if c else 1.0-dpi[j+1] return r dp = [[0]*(r+1) for i in xrange(c+1)] ans = 0.0 for i in xrange(r): si = s[i] pi = p[i] dpp = dp[i-1] dpi = dp[i] for k in xrange(1000): for j in xrange(c): if si[j]==0: dpi[j] = pi[j]/100.0 elif si[j]==1: dpi[j] = pi[j]*(1.0 - f(0,0,0))/100.0 elif si[j]==2: dpi[j] = pi[j]*(f(1,1,1)+f(1,1,0)+f(1,0,1)+f(1,1,0))/100.0 elif si[j]==3: dpi[j] = pi[j]*f(1,1,1)/100.0 else: dpi[j] = 0.0 for j in xrange(c): ans += dpi[j] print ans