#include <cmath> #include <cstdio> #include <vector> #include <set> #include <iostream> #include <algorithm> using namespace std; int main() { int n; cin >> n; set<int> stx,sty; for (int i = 0; i < n; i++) { int x,y; cin >> x >> y; stx.insert(x); sty.insert(y); } if (stx.size() == 1 || sty.size() == 1) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }