#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define reE(i,a,b) for(auto (i)=(a);(i)<=(b);(i)++) #define rE(i,b) reE(i,0,b) #define reT(i,a,b) for(auto (i)=(a);(i)<(b);(i)++) #define rT(i,b) reT(i,0,b) #define rep(i,a,b) reE(i,a,b); #define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--) #define fe(i,b) for (auto &(x):b); #define itr(i,b) for(auto (i)=(b).begin();(i)!=(b).end();++(i)) #define rti(i,b) for(auto (i)=(b).rbegin();(i)!=(b).rend();++(i)) #define LL long long int bw[100][100]; int c[100][100]; string str; int h, w; bool board(){ int r = 0, b = 0; rT(i, h) rT(j, w){ if (c[i][j] == 1)r++; else if (c[i][j] == 2)b ++; c[i][j] = bw[i][j]; } return (r>0&&b>0&&r==b); } int main(void){ cin >> h >> w; int t=0; rT(i, h){ cin >> str; rT(j, w){ if (str[j] == '.')bw[i][j] = -1; else bw[i][j] = 0,t++; } } if (t == 0){ cout << "YES" << endl; return 0; } board(); rT(i,h) rT(j, w){ if (i == 0 && j == 0)continue; bool flag = true; rT(x, h) rT(y, w){ if (c[x][y] == 0){ c[x][y] = 1; if (x + i >= h || y + j >= w ) flag = false; else if (c[x + i][y + j] != 0) flag = false; else c[x + i][y + j] = 2; } } flag &= board(); if (flag){ cout << "YES" << endl; return 0; } } cout << "NO" << endl; return(0); }