#include using namespace std; #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define mp(a,b) make_pair((a),(b)) #define pb(a) push_back((a)) #define all(x) (x).begin(),(x).end() #define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x)) #define fi first #define se second #define dbg(x) cout<<#x" = "<<((x))< ostream& operator<<(ostream& o, const pair &p){o<<"("< ostream& operator<<(ostream& o, const vector &v){o<<"[";for(T t:v){o<>h>>w; vector vec(h); rep(i,h) cin>>vec[i]; int cnt=0; rep(i,h)rep(j,w) if(vec[i][j]=='#') cnt++; if(cnt==0) return false; if(cnt%2==1) return false; auto isok = [&](int dx, int dy){ vector> checked(h,vector(w,false)); rep(i,h)rep(j,w) if(vec[i][j]=='#' && checked[i][j]==false){ int nx = i+dx, ny = j+dy; if(nx<0 || ny<0 || nx>=h || ny>=w) return false; if(vec[nx][ny]=='.') return false; checked[nx][ny] = true; }//dbg(mp(dx,dy)); return true; }; for(int i=-h; i