#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int H, W; cin >> H >> W; vector tile(H); set> black; enum { width = 0, height = 1 }; for(int i=0; i> tile[i]; for(int j=0; j> b(black); for(const auto& t : b) { int x = get(t)+w; int y = get(t)+h; if(b.count(make_tuple(x, y)) == 0) break; b.erase(make_tuple(x, y)); } if(b.size() == black.size()/2) { cout << "YES" << endl; return 0; } } } cout << "NO" << endl; }