#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for (int i = 0; i < (int)(n); ++i) //#define cerr if(false) cerr #ifdef DEBUG #define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__); #else #define show(...) 42 #endif using namespace std; using ll = long long; using pii = pair; template ostream& operator<<(ostream& os, pair a) { os << '(' << a.first << ',' << a.second << ')'; return os; } template ostream& operator<<(ostream& os, vector v) { for (auto x : v) os << x << ' '; return os; } void debug() { cerr << '\n'; } template void debug(H a, T... b) { cerr << a; if (sizeof...(b)) cerr << ", "; debug(b...); } int main(){ int h, w; cin >> h >> w; vectors(h); rep(i,h)cin >> s[i]; int cnt = 0; rep(i,h)rep(j,w)cnt += s[i][j] == '#'; if(cnt == 0){ puts("NO"); return 0; } for(int i = - h; i <= h; i++){ for(int j = - w; j <= w; j++){ vector> used(h, vector(w)); bool f = true; rep(x, h){ rep(y, w){ if(used[x][y])continue; used[x][y] = true; if(s[x][y] == '#'){ int xx = x + i; int yy = y + j; if(xx < 0 or xx >= h or yy < 0 or yy >= w){ f = false; continue; } if(used[xx][yy])f = false; used[xx][yy] = true; if(s[xx][yy] != '#'){ f = false; } } } } if(f){ show(i, j); puts("YES"); return 0; } } } puts("NO"); return 0; }