#include<bits/stdc++.h>
#define N 500
using namespace std;
int f[N],sz[N],fl[N],out[N],in[N];
int n,h,a,b,c,d,x,y;
int get(int x){
	return f[x]==x?x:f[x]=get(f[x]);
}
int main(){
	scanf("%d%d",&n,&h);
	for (int i=-h;i<=h;i++)
		f[i+233]=i+233,sz[i+233]=1;
	for (int i=1;i<=n;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		x=(c==0)?a:-c; y=(d==0)?-b:d;
		++out[x+233]; ++in[y+233];
		x=get(x+233); y=get(y+233);
		if (x==y) sz[x]++;
		else f[x]=y,sz[y]+=sz[x]+1;
	}
	for (int i=1;i<=h;i++)
		if (out[i+233]<in[i+233])
			return puts("NO"),0;
	for (int i=-h;i<=-1;i++)
		if (in[i+233]<out[i+233])
			return puts("NO"),0;
	for (int i=-h;i<=h;i++)
		fl[get(i+233)]|=(in[i+233]!=out[i+233]);
	for (int i=-h;i<=-1;i++)
		if (sz[get(i+233)]>1&&!fl[get(i+233)])
			return puts("NO"),0;
	for (int i=1;i<=h;i++)
		if (sz[get(i+233)]>1&&!fl[get(i+233)])
			return puts("NO"),0;
	puts("YES"); 
} 