#include #include #include #include #include int main() { int N; int x,xx; int y,yy; std::cin >> N; int xa=1; int ya=1; std::cin >> x >> y; for(size_t i=0; i> xx >> yy; if(xx!=x) xa=0; if(yy!=y) ya=0; x=xx; y=yy; } if(xa || ya) std::cout << "YES" << std::endl; else std::cout << "NO" << std::endl; return 0; }