#include using namespace std; #include using namespace atcoder; //using mint = static_modint<998244353>; //using mint = modint; using mint = static_modint<1000000007>; using vm = vector; using vvm = vector; ostream &operator<<(ostream &o,const mint &m){cout<; using vvl = vector; using pl = pair; using vp = vector; #define rep(i,n) for(ll i=0;i<(ll)(n);++i) #define reps(i,s,n) for(ll i=(s);i<(ll)(n);++i) #define rep1(i,n) for(ll i=1;i<=(ll)(n);++i) templateinline bool chmax(T &a,T b){return ainline bool chmin(T &a,T b){return a>b?a=b,true:false;} #define fi first #define se second #define pb push_back #define eb emplace_back #define be(v) (v).begin(),(v).end() const long long INF = 1e18; #ifdef DEBUG #include random_device rd; mt19937 gen(rd()); ll random(ll l,ll h){ uniform_int_distribution dist(l,h); return dist(gen); } #endif ll H,W; vector S,R; void input(){ cin>>H>>W; S.assign(H,string()); R.assign(W,string()); rep(h,H){ cin>>S.at(h); rep(w,W){ R.at(w).pb(S.at(h).at(w)); } } } #ifdef DEBUG void showall(){ show(H,W,S,R); } #endif ll ichimatsu(vector vs){ bool od=false, ev=false; rep(i,vs.size())rep(j,vs.at(i).size()){ char c = vs.at(i).at(j); if(c == '0'){ if((i + j)%2) ev=true; else od=true; }else if(c == '1'){ if((i + j)%2) od=true; else ev=true; } } if(od && ev) return 0; if(!od && !ev) return 2; else return 1; } mint check(vector vs){ ll cnt=0; for(auto s:vs){ bool od=false, ev=false; rep(i,s.size()){ if(s.at(i) == '0'){ if(i%2) ev=true; else od=true; }else if(s.at(i) == '1'){ if(i%2) od=true; else ev=true; } } if(od && ev) return 0; if(!od && !ev) ++cnt; } return mint(2).pow(cnt); } void logic(){ mint ans = check(S); ans += check(R); ans -= ichimatsu(S); cout<