#include #include #include #include #include #include #include #include #include // require sort next_permutation count __gcd reverse etc. #include // require abs exit atof atoi #include // require scanf printf #include #include // require accumulate #include // require fabs #include #include #include #include // require setw #include // require stringstream #include // require memset #include // require tolower, toupper #include // require freopen #include // require srand #define rep(i,n) for(int i=0;i<(n);i++) #define ALL(A) A.begin(), A.end() #define each(i,c) for(auto i=(c).begin();i!=(c).end();++i) #define exist(s,e) ((s).find(e)!=(s).end()) #define clr(a) memset((a),0,sizeof(a)) #define nclr(a) memset((a),-1,sizoef(a)) #define sz(s) (int)((s).size()) #define INRANGE(x,s,e) ((s)<=(x) && (x)<(e)) #define pb push_back #define MP(x,y) make_pair((x),(y)) #define NOCOLOR -1 #define RED 0 #define BLUE 1 using namespace std; typedef long long ll; typedef pair P; char board[52][52]; int color[52][52]; int H, W; bool solve (void ){ int cnt = 0; rep (i, H ) rep (j, W ) cnt += (board[i][j] == '#' ); if (cnt == 0 || cnt == 1 ) return false; rep (dy, H ){ for (int dx = -W; dx <= W; dx++ ){ if (dy == 0 && dx == 0 ) continue; memset (color, NOCOLOR, sizeof (color ) ); bool ok = true; rep (i, H ) rep (j, W ){ if (board[i][j] == '#' && color[i][j] == NOCOLOR ) { int nr = i + dy; int nc = j + dx; if (nr < 0 || nc < 0 || nr >= H || nc >= W ) { ok = false; break; } // end if if (board[nr][nc] == '#' && color[nr][nc] == NOCOLOR ){ color[i][j] = RED; color[nr][nc] = BLUE; }else{ ok = false; break; } // end if } // end if } // end rep if (ok ) return true; } // end rep } // end rep return false; } int main() { memset (board, 0, sizeof (board ) ); memset (color, 0, sizeof (color ) ); ios_base::sync_with_stdio(0); cin >> H >> W; rep (i, H ) rep (j, W ) cin >> board[i][j]; bool res = solve (); cout << (res ? "YES" : "NO" ) << endl; return 0; }