//Archit Rai
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(a) (int)(a.size())
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long int ll;
ll powmod(ll a,ll b)
{
    if(b==0)return 1;
    ll x=powmod(a,b/2);
    ll y=(x*x)%MOD;
    if(b%2)
        return (a*y)%MOD;
    return y%MOD;
}
//Template ends here

int main()
{
    int n;
    si(n);
    set<int> s,t;
    REP(i,0,n)
    {
	int x;
	int y;
	si(x),si(y);
	s.insert(x);
	t.insert(y);
    }
    if(sz(s)==1 || sz(t)==1)
	printf("YES\n");
    else
	printf("NO\n");
    return 0;
}