#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,h;
  cin>>n>>h;
  vector<Int> a(n),b(n),c(n),d(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];

  const Int MAX = 300;
  vector<vector<Int> > G(MAX*2);
  vector<Int> od(MAX*2,0),id(MAX*2,0);
  for(Int i=0;i<n;i++){
    Int l=c[i]==0? a[i]:-c[i];
    Int r=d[i]==0?-b[i]: d[i];
    G[MAX+l].emplace_back(MAX+r);
    od[MAX+l]++;
    id[MAX+r]++;
  }
  
  auto NO=[](){cout<<"NO"<<endl;exit(0);};
  
  Int w=0;
  for(Int i=1;i<MAX;i++){    
    while(od[MAX+i]>id[MAX+i]){
      G[MAX+w].emplace_back(MAX+i);
      od[MAX+w]++;
      id[MAX+i]++;
    }
    while(od[MAX-i]<id[MAX-i]){
      G[MAX-i].emplace_back(MAX-w);
      od[MAX-i]++;
      id[MAX-w]++;
    }
    //cout<<i<<"+:"<<od[MAX+i]<<" "<<id[MAX+i]<<endl;
    //cout<<i<<"-:"<<od[MAX-i]<<" "<<id[MAX-i]<<endl;
    if(od[MAX+i]!=id[MAX+i]) NO();
    if(od[MAX-i]!=id[MAX-i]) NO();
  }

  vector<Int> used(MAX*2);
  queue<Int> q;

  used[MAX+w]=1;
  q.emplace(MAX+w);
  
  while(!q.empty()){
    Int v=q.front();q.pop();
    for(Int u:G[v]){
      if(used[u]) continue;
      used[u]=1;
      q.emplace(u);
    }
  }
  
  for(Int i=0;i<MAX*2;i++)
    if((id[i]||od[i])&&!used[i]) NO();
  
  cout<<"YES"<<endl;
  return 0;
}
