#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void solve() { int h, w; std::cin >> h >> w; std::vector g(h); for (auto& s : g) std::cin >> s; int cnt = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (g[i][j] == '#') cnt++; } } if (cnt & 1 or cnt == 0) { std::cout << "NO\n"; return; } for (int dx = 1 - h; dx < h; dx++) { for (int dy = 1 - w; dy < w; dy++) { if (!dx and !dy) continue; auto t = g; int c = 0; for (int x = 0; x < h; x++) { for (int y = 0; y < w; y++) { if (t[x][y] == '#') { int nx = x + dx, ny = y + dy; if (nx >= 0 and ny >= 0 and nx < h and ny < w and t[nx][ny] == '#') { t[x][y] = 'R'; t[nx][ny] = 'B'; c += 2; } } } } if (cnt == c) { std::cout << "YES" << '\n'; return; } } } std::cout << "NO" << '\n'; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int t = 1; // std::cin >> t; while (t--) solve(); // solve(); return 0; }