/* ===================================*/ /* Author : Moshiur Rahman Mohim */ /* Email : mtmohim74@gmail.com */ /* Institute: HSTU */ /* ===================================*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int INF = 0x7f7f7f7f; #define pi acos(-1.0) #define mod 1000000007 #define MAX 10000 #define FOR(i, b, n) for(LL i=b; i<=n; i++) #define FORR(i, n, b) for(LL i=n; i>=b; i--) // Library. #define mem(a,b) memset(a,b,sizeof(a)) #define Sort(x) sort(x.begin(),x.end()) #define Reverse(x) reverse(x.begin(),x.end()) #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a * (b / gcd(a,b))) #define sq(x) (x)*(x) // File. #define READ(f) freopen(f, "r", stdin) #define WRITE(f) freopen(f, "w", stdout) // i/o. #define sf scanf #define pf printf #define pr1(x) cout<vl; typedef pairpii; typedef pairpsi; typedef pairpll; typedef pairpdd; typedef vector vpii; // Compute b^p%m int BigMod(LL B,LL P,LL M) { LL R=1; while(P>0) { if(P%2==1) R=(R*B)%M; P/=2; B=(B*B)%M; } return (int)R; } /*............End............*/ /*.......Global Declaration.......*/ LL ar1[20],ar2[20]; int main() { //READ("input.txt"); //WRITE("output.txt"); LL n,m,b,c,d,x,y,s; cin>>n; x=0; y=0; FOR(i,1,n) { cin>>ar1[i]>>ar2[i]; if(i!=1) { if(ar1[i]==ar1[i-1]) x+=1; if(ar2[i]==ar2[i-1]) y+=1; } } if(x==n-1 || y==n-1) pf("YES\n"); else pf("NO\n"); return 0; }