from itertools import product inputs = lambda:map(int, raw_input().split()) r, c = inputs() raw_input() p = [inputs() + [0] for i in xrange(r)] + [0]*(c+1) raw_input() s = [inputs() + [4] for i in xrange(r)] + [4]*(c+1) dp = [[0]*(2**c) for i in xrange(r+1)] def bit_get(v, i): if i<0: return 0 return (v>>i) & 1 def f(a, b, c): r = pp[j] if a else 100-pp[j] r *= pi[j-1] if b else 100-pi[j-1] r *= pi[j+1] if c else 100-pi[j+1] return r/1000000.0 dp[0][0] = 1. ans = 0 for i in xrange(r): sp = s[i-1] si = s[i] pp = s[i] pi = p[i] dpp = dp[i] dpi = dp[i+1] for S in xrange(2**c): if dpp[S]==0.0: continue for T in xrange(2**c): res = dpp[S] for j in xrange(c): if si[j]==0: res *= (pi[j] if bit_get(T, j) else 100-pi[j])/100.0 else: x, y, z = bit_get(S, j), bit_get(T, j-1), bit_get(T, j+1) #print i, bin(S), bin(T) #print x, y, z, f(x, y, z) if x+y+z >= si[j]: #res *= (pi[j] if bit_get(T, j) else 100-pi[j])*f(x, y, z)/100.0 res *= (pi[j] if bit_get(T, j) else 100-pi[j])/100.0 else: if bit_get(T, j): res = 0.0 break dpi[T] += res #print bin(T), res #print i, "result" for T in xrange(2**c): #print bin(T), dpi[T] ans += bin(T).count("1") * dpi[T] #print dp print ans