#include using namespace std; int main() { int h, w; cin >> h; cin >> w; int sum = 0; char c; bool** dp = new bool*[h]; for (int i = 0; i < h; ++i) { dp[i] = new bool[w]; for (int j = 0; j < w; ++j) { cin >> c; if (c == '#') { ++sum; dp[i][j] = true; } else{ dp[i][j] = false; } } } if (sum % 2 == 1) { cout << "NO" << endl; return 0; } int count = 0; for (int i = 0; i < h; ++i) { for (int j = 1; j < w; ++j, count = 0) { for (int a = 0; a < h - i; ++a) { for (int b = 0; b < w - j; ++b) { if (dp[a + i][b + j] && dp[a][b]) { ++count; } } } if (count == sum / 2) { cout << "YES" << endl; return 0; } } for (int j = -(w - 1); j < 0; ++j, count = 0) { for (int a = 0; a < h - i; ++a) { for (int b = 0; b < w + j; ++b) { if (dp[a + i][b] && dp[a][b - j]) { ++count; } } } if (count == sum / 2) { cout << "YES" << endl; return 0; } } } cout << "NO" << endl; return 0; }