#include #include #include #include #include #include #include #include #include #include using namespace std; template T next_int() { long long x; scanf("%lld", &x); return x; /* T x = 0, p = 1; char ch; do { ch = getchar(); } while(ch <= ' '); if (ch == '-') { p = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') { x = x * 10 + (ch - '0'); ch = getchar(); } return x * p; */ } const int max_n = (int)2e3 + 227 + 1; const int max_int = (int)1e9 + 227 + 1; const int mod = (int)1e9 + 7; map a, b; int main() { // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); int n; cin >> n; for(int i = 0; i < n; i++) { a[next_int()]++; b[next_int()]++; } if(a.size() == 1 || b.size() == 1) puts("YES"); else puts("NO"); }