#include<bits/stdc++.h>
int n,H,in[411],out[411];
bool e[411][411],d[411];
void dfs(int w){
	d[w]=1;
	for(int i=0;i<=H*2;++i)if(e[w][i]&&!d[i])dfs(i);
}
void ae(int x,int y){
	++out[x],++in[y];
	e[x][y]=1;
}
int main(){
	scanf("%d%d",&n,&H);
	for(int i=0,a,b,c,d;i<n;++i){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		ae(c?H+c:a,d?d:H+b);
	}
	for(int i=1;i<=H;++i){
		int w=i;
		if(in[w]>out[w])return puts("NO"),0;
		while(in[w]<out[w])ae(0,w);
		w=H+i;
		if(in[w]<out[w])return puts("NO"),0;
		while(in[w]>out[w])ae(w,0);
	}
	if(in[0]!=out[0])return puts("NO"),0;
	dfs(0);
	for(int i=1;i<=H*2;++i)if((in[i]|out[i])&&!d[i])return puts("NO"),0;
	return puts("YES"),0;
}