#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=beg[j];i;i=nex[i])
using namespace std;
int const mn=1e5+3,mh=203;
int n,h,gra,beg[mh*2],to[mn],nex[mn],vis[mh*2],ind[mh*2],outd[mh*2];
void ins(int u,int v){
	to[++gra]=v;
	nex[gra]=beg[u];
	beg[u]=gra;
}
void dfs(int p){
	vis[p]=1;
	fr(i,p)if(!vis[to[i]])dfs(to[i]);
}
int main(){
	scanf("%d%d",&n,&h);
	fo(i,1,n){
		int a,b,c,d,x,y;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(c)x=-c;else x=a;
		if(d)y=d;else y=-b;
		x+=h;y+=h;
		ins(x,y);
		ind[y]++;
		outd[x]++;
	}
	fo(i,0,h)if(outd[i]>ind[i]){printf("NO");return 0;}
	fo(i,h,h*2)if(outd[i]<ind[i]){printf("NO");return 0;}
	fo(i,0,h*2)if((ind[i]!=outd[i])&&(!vis[i]))dfs(i);
	fo(i,0,h*2)if((ind[i]||outd[i])&&(!vis[i])){printf("NO");return 0;}
	printf("YES");
	return 0;
}
