#include using namespace std; //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); #define trace1(x) cerr << #x << ": " << x << endl; #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl; #define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl; #define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl; #define bitcount __builtin_popcountll #define sd(x) scanf("%d",&x) #define slld(x) scanf("%lld",&x) #define ss(x) scanf("%s",x) #define ll long long #define mp(a,b) make_pair(a,b) #define F first #define S second #define pb(x) push_back(x) #define MOD 1000000007 #define MAX 100005 int a[50],b[50]; int main() { //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; for(int i=1;i<=n;i++) { int x,y; cin>>a[i]>>b[i]; } int x=a[1]; int y=b[1]; int p=1; int q=1; for(int i=2;i<=n;i++) { if(a[i]==x) { p++; } if(b[i]==y) { q++; } } if(p==n||q==n) { cout<<"YES"; } else cout<<"NO"; return 0; }