using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (h, w) = (c[0], c[1]); var s = SList(h); var t = SList(h); var first = Connect(s, t); var second = Connect(Reverse(s), t); var fail = 1.0; var mul = 1.0; var ans = 0.0; for (var i = 1; i < 100; ++i) { if ((i % 2 == 1 && first) || (i % 2 == 0 && second)) { ans += i * mul * (1 - fail); mul *= fail; } fail /= 2; } WriteLine(ans); } static string[] Reverse(string[] s) { var ans = new string[s.Length]; for (var i = 0; i < s.Length; ++i) ans[i] = string.Concat(s[s.Length - i - 1].Reverse()); return ans; } static bool Connect(string[] s, string[] t) { for (var i = 0; i < s.Length; ++i) for (var j = 0; j < s[0].Length; ++j) if (s[i][j] == t[i][j]) return false; return true; } }