#include using namespace std; using ll = long long; template using min_priority_queue = priority_queue, greater>; using pii = pair; using pll = pair; using Graph = vector>; const ll INF = 1LL << 60; template void chmax(T& a, T b) { if (b > a) a = b; } template void chmin(T& a, T b) { if (b < a) a = b; } template std::ostream& operator<<(std::ostream& os, const pair& x) noexcept { return os << "(" << x.first << ", " << x.second << ")"; } template void print_vector(vector a) { cout << '['; for (int i = 0; i < a.size(); i++) { cout << a[i]; if (i != a.size() - 1) { cout << ", "; } } cout << ']' << endl; } template vector s2v(set& s) { vector vec; for (auto& v : s) { vec.push_back(v); } return vec; } bool is_ok(int i0, int j0, vector>& Mat) { ll H = Mat.size(); ll W = Mat[0].size(); set reds, blues; for (int i = H - 1; i >= 0; i--) { for (int j = W - 1; j >= 0; j--) { if (Mat[i][j] == '#') { if (i >= i0 && j >= j0) { if (blues.count({i, j})) { reds.insert({i, j}); } else { blues.insert({i - i0, j - j0}); } } else { reds.insert({i, j}); } } } } if (reds.size() != blues.size()) { return false; } if (reds.size() == 0) { return false; } auto reds_vec = s2v(reds); auto blues_vec = s2v(blues); ll N = reds.size(); sort(reds_vec.begin(), reds_vec.end()); sort(blues_vec.begin(), blues_vec.end()); for (int i = 0; i < N; i++) { if (reds_vec[i].first != blues_vec[i].first) return false; if (reds_vec[i].second != blues_vec[i].second) return false; } return true; } int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); ll H, W; cin >> H >> W; vector> Mat(H, vector(W, 0)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> Mat[i][j]; } } for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (i == 0 && j == 0) continue; if (is_ok(i, j, Mat)) { std::cout << "YES" << "\n"; return 0; } } } std::cout << "NO" << "\n"; return 0; }