#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int H, W, c[50][50]; string S[50]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> H >> W; rep(y, H)cin >> S[y]; FOR(dy, -H + 1, H)FOR(dx, -W + 1, W) if (dy != 0 || dx != 0) { MEM(c, 0); bool ok = [&] { rep(y, H)rep(x, W) if (S[y][x] == '#' && !c[y][x]) { c[y][x] = 1; int ny = y + dy, nx = x + dx; if (ny >= H || nx >= W || ny < 0 || nx < 0 || S[ny][nx] != '#' || c[ny][nx]) { return false; } c[ny][nx] = 1; } return true; }(); if (ok) { cout << "YES" << endl; return 0; } } cout << "NO" << endl; }