#include #include #include #include using namespace std; int main() { int H, W; cin >> H >> W; vector fi(H); for (int i = 0; i < H; ++i) cin >> fi[i]; reverse(fi.begin(), fi.end()); int a = 0, b = 0; for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { if (fi[i][j] == 'o') { if ( (i + j) % 2 == 0 ) ++a; else ++b; } } } if ( (a - b) % 3 == 0 ) cout << "YES" << endl; else cout << "NO" << endl; }