#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define rng(a) a.begin(),a.end() using namespace std; typedef long long int ll; typedef pair P; typedef vector vi; typedef vector vvi; typedef vector vl; typedef vector

vp; #define dame { puts("-1"); return 0;} #define yn {puts("YES");}else{puts("NO");} #define MAX_N 200005 int main() { int n; cin >> n; int flag = 0; rep(i,3){ int x,y; if(i==0){x = 2; y = 8;} if(i==1){x = 3; y = 9;} if(i==2){x = 7; y = 9;} rep(j,n){ int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2; if(x==x1&&y==y1){x = x2; y = y2;} } if(i==0 && (x!=5 || y!=8))flag = 1; if(i==1 && (x!=4 || y!=8))flag = 1; if(i==2 && (x!=6 || y!=8))flag = 1; } if(flag == 0)yn; return 0; }