#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 bool check(vector x,vector y){ rep(i,x.size()){ rep(j,x[i].size()){ if(x[i][j]==y[i][j])return false; } } return true; } int main(){ int h,w; cin>>h>>w; vector s(h),t(h); rep(i,h)cin>>s[i]; rep(i,h)cin>>t[i]; bool f0 = check(s,t); rep(i,h){ reverse(t[i].begin(),t[i].end()); } reverse(t.begin(),t.end()); bool f1 = check(s,t); double ans = 0,cp = 1; rep(i,5000000){ double p = 0; if(i%2==0&&f0)p = 1-pow(2.0,-i); if(i%2==1&&f1)p = 1-pow(2.0,-i); ans += cp*p*(i+1); cp *= 1-p; } cout<