#include using namespace std; template bool chmax(T &a, const T &b){ if (a >= b){ return false; } a = b; return true; } template bool chmin(T &a, const T &b){ if (a <= b){ return false; } a = b; return true; } vector> max_ur(vector> &a){ int h = a.size(); int w = a[0].size(); vector> ans(h,vector(w,0)); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){ if (a[i][j] == '#'){ ans[i][j] = 1; if (i > 0 && j > 0){ chmax(ans[i][j],ans[i-1][j-1]+1); } } } return ans; } template void rotated(vector> &a){ int h = a.size(); int w = a[0].size(); vector> b(w,vector(h)); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){ b[j][h-1-i] = a[i][j]; } swap(a,b); } int main(){ int h, w; cin >> h >> w; vector> a(h,vector(w)); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){ cin >> a[i][j]; } vector> dp(h,vector(w,h+w)); for (int t = 0; t < 4; t++){ auto ep = max_ur(a); for (int s = 0; s < 4-t; s++){ rotated(ep); } for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){ chmin(dp[i][j],ep[i][j]); } rotated(a); } vector> imosm(h,vector(w,0)), imosp(h,vector(w,0)); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){ if (dp[i][j] <= 1) continue; int r = dp[i][j]-1; imosm[i-r][j-r]++; if (i+r+1 < h && j+r+1 < w){ imosm[i+r+1][j+r+1]--; } imosp[i-r][j+r]++; if (i+r+1 < h && j-r-1 >= 0){ imosp[i+r+1][j-r-1]--; } } for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){ if (i+1 < h && j+1 < w){ imosm[i+1][j+1] += imosm[i][j]; } if (i+1 < h && j-1 >= 0){ imosp[i+1][j-1] += imosp[i][j]; } } bool ans = true; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){ if (a[i][j] == '#' && imosm[i][j]+imosp[i][j] == 0){ ans = false; break; } } cout << (ans ? "Yes" : "No") << endl; }