#include #include #define pb push_back #define mp make_pair #define mt make_tuple #define ll long long #define pii pair #define tii tuple #define N 1000005 #define mod 2000003 #define X first #define Y second #define eps 0.0000000001 #define all(x) x.begin(),x.end() #define tot(x) x+1,x+n+1 using namespace std; int x,y,i,n; sets,t; int main() { cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin>>n; for(i=1; i<=n; i++) { cin>>x>>y; s.insert(x); t.insert(y); } if(s.size()==1||t.size()==1) cout<<"YES"; else cout<<"NO"; return 0; }