using System; using System.IO; using System.Linq; using System.Text; using System.Collections.Generic; using System.Diagnostics; using System.Numerics; using Enu = System.Linq.Enumerable; class Program { static readonly int Threshold = 4; public void Solve() { int H = Reader.Int(), W = Reader.Int(); var Prob = new double[H][]; var Val = new int[H][]; for (int r = 0; r < H; r++) { Prob[r] = new double[W]; for (int c = 0; c < W; c++) Prob[r][c] = Reader.Int() / 100.0; } for (int r = 0; r < H; r++) { Val[r] = new int[W]; for (int c = 0; c < W; c++) Val[r][c] = Threshold - Reader.Int(); } var dp = new double[1 << W]; dp[0] = 1; double ans = 0; for (int r = 0; r < H; r++) { var nextdp = new double[1 << W]; for (int prevMask = 0; prevMask < (1 << W); prevMask++) if (dp[prevMask] > 0) for (int currMask = 0; currMask < (1 << W); currMask++) { double p = dp[prevMask]; for (int c = 0; c < W; c++) if ((currMask >> c & 1) == 1) p *= Prob[r][c]; else p *= 1 - Prob[r][c]; int atLast = Simulate(Val, r, prevMask, currMask); ans += p * BitCount32(atLast); nextdp[atLast] += p; } dp = nextdp; } Console.WriteLine(ans); } private static int Simulate(int[][] Val, int r, int prevMask, int currMask) { int W = Val[0].Length; int[] pt = new int[W]; var who = new List(); int stands = 0; Action> Add = (w, list) => { stands += 1 << w; list.Add(w); }; for (int c = 0; c < W; c++) { if (r > 0) pt[c] = prevMask >> c & 1; pt[c] += Val[r][c] * (currMask >> c & 1); if (pt[c] >= Threshold) Add(c, who); } while (who.Count > 0) { var nextWho = new List(); foreach (int c in who) { if (c - 1 >= 0 && ++pt[c - 1] == Threshold) Add(c - 1, nextWho); if (c + 1 < W && ++pt[c + 1] == Threshold) Add(c + 1, nextWho); } who = nextWho; } return stands; } static int BitCount32(int x) { x -= x >> 1 & 0x55555555; x = (x & 0x33333333) + (x >> 2 & 0x33333333); return ((x + (x >> 4) & 0x0f0f0f0f) * 0x01010101) >> 24; } } class Entry { static void Main() { new Program().Solve(); } } class Reader { private static TextReader reader = Console.In; private static readonly char[] separator = { ' ' }; private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries; private static string[] A = new string[0]; private static int i; private static void Init() { A = new string[0]; } public static void Set(TextReader r) { reader = r; Init(); } public static void Set(string file) { reader = new StreamReader(file); Init(); } public static bool HasNext() { return CheckNext(); } public static string String() { return Next(); } public static int Int() { return int.Parse(Next()); } public static long Long() { return long.Parse(Next()); } public static double Double() { return double.Parse(Next()); } public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); } public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); } public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); } public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Next()).ToArray(); } public static string Line() { return reader.ReadLine().Trim(); } private static string[] Split(string s) { return s.Split(separator, op); } private static string Next() { CheckNext(); return A[i++]; } private static bool CheckNext() { if (i < A.Length) return true; string line = reader.ReadLine(); if (line == null) return false; if (line == "") return CheckNext(); A = Split(line); i = 0; return true; } }