#include #include #include #include #include "queue" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define MOD 1000000007 #define pi acos(-1) #define iil pair #define vii vector #define ll long long int #define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;i--) #define REP(i,a,b) for(ll i=a;i<=b;i++) #define loop(i,n) for(ll i=0;i (b) ? (a) : (b) #define ABS(a) (a) > 0 ? (a) : -(a) #define rep1(i,a,n) for(i=a;i<(n);i++) #define pii pair< ll, ll > #define pb push_back #define mp make_pair #define FOR(i,a,b) for (int _n(b), i(a); i <= _n; i++) #define rept(i,n) FOR(i,0,(n)-1) #define edge pair ll add(ll a, ll b) { return a+b-(a+b>=MOD)*MOD; } ll sub(ll a, ll b) { return a-b+(a-b<0)*MOD; } ll mult(ll a, ll b) { return (1LL*a*b)%MOD; } #define all(x) (x).begin(),(x).end() inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; } #define dis(x,y,a,b) sqrt((x-a)*(x-a)+(y-b)*(y-b)); #define maxn 100005 #define rep(i,a,n) for (int i=a;i 0) { if (exponent % 2 == 1) result = (result * base) % modulus; exponent = exponent >> 1; base = (base * base) % modulus; } return result; } using namespace std; ///////////////////////////////////////StillHungry//////////////////////////////// //WHEN WILL I GET ACs /* Success is a journey not a destination a year from now you may wish you had started today. Every beginner is a winner. Success is not escaping problems but facing them creatively. There is no success without sacrifice. Great success always calls for great sacrifice. Even failure can become an important ingredient to success. Failure just means that you have not yet succeeded. */ //I can't change the direction of the wind, but I can adjust my sails to always reach my destination. //S:15 US:12 //Kingfish(a**********)(X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X) //X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X bool check1(ll array1[],ll n) { ll consta = array1[0]; loop(i, n){ if(array1[i]!=consta){ return false; } } return true; } int main() { ios::sync_with_stdio(false); cin.tie(); ll n; cin>>n; ll array1[n]; ll array2[n]; loop(i, n){ cin>>array1[i]>>array2[i]; } if(check1(array1, n)||check1(array2, n)){ cout<<"YES"; } else{ cout<<"NO"; } return 0; }