#include #define ll long long #define F first #define S second #define y1 qwe_y1 #define y2 qwe_y2 using namespace std; const ll INF = 1e9 + 7; map mp1, mp2; ll a, b, n; int main(){ ios_base::sync_with_stdio(false); cin >> n; for(int i = 1; i <= n; i++){ cin >> a >> b; mp1[a] = 1; mp2[b] = 1; } if(mp1.size() == 1 || mp2.size() == 1){ cout << "YES"; } else { cout << "NO"; } }