#include using namespace std; bool inside(int a, int b, int alim, int blim){ return 0 <= a && a < alim && 0 <= b && b < blim; } int main(){ int h, w; cin >> h >> w; string s[h]; for(int i = 0; i < h; i++) cin >> s[i]; { bool f = true; for(int i = 0; i < h; i++) for(auto& c:s[i]) f &= c == '.'; if(f){ cout << "NO" << endl; return 0; } } for(int mh = -h; mh <= h; mh++) for(int mw = -w; mw <= w; mw++){ if(mh == 0 && mw == 0) continue; bool f = true, done[h][w]{}; for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(s[i][j] == '#' && !done[i][j]){ if(!inside(i + mh, j + mw, h, w)) goto next; if(s[i + mh][j + mw] != '#' || done[i + mh][j + mw]) goto next; done[i][j] = done[i + mh][j + mw] = true; } for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(s[i][j] == '#') f &= done[i][j]; if(f){ cout << "YES" << endl; return 0; } next:; } cout << "NO" << endl; }