#include using namespace std; using ll = long long; #include using mint = atcoder::modint998244353; using B = bitset<1000>; #include int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int h,w; cin>>h>>w; vector> a(h,vector(w,0)); for(int i = 0;i>a[i][j]; vector>> use; for(int i = 0;i> ok(h,vector(w,0)); vector c(w); atcoder::dsu uf(w); for(int i = 0;i0) uf.merge(j,k); for(auto&now:uf.groups()){ B use; for(auto&j:now) use |= c[j]; for(auto&j:now) c[j] = use; } } cout<