#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  typedef pair<int,int> P;
  P a,b,c;a=P(2,8);b=P(3,9);c=P(7,9);
  while(N--){
    int x,y,x2,y2;cin>>x>>y>>x2>>y2;
    if(a==P(x,y))a=P(x2,y2);
    if(b==P(x,y))b=P(x2,y2);
    if(c==P(x,y))c=P(x2,y2);
  }
  if(a==P(5,8)&&b==P(4,8)&&c==P(6,8))cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}