#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1000005;
int n,h,i,j,k,l,ans,A,B,C,D,g[405][405],u[N],p[N],ind[N],outd[N];
bool vis[N],ok[N];
int find(int x)
{
	return p[x]==-1?x:p[x]=find(p[x]);
}
int main()
{
	scanf("%d%d",&n,&h);
	for(i=1;i<=n;++i)
	{
		scanf("%d%d%d%d",&A,&B,&C,&D);
		if(C)
			A=C+h;
		if(D)
			B=D+h;
		g[A][B<=h?B+h:B-h]++;
		vis[A]=vis[B<=h?B+h:B-h]=true;
	}
	for(i=1;i<=2*h;++i)
		for(j=1;j<=2*h;++j)
			ind[j]+=g[i][j],outd[i]+=g[i][j];
	for(i=1;i<=h;++i)
		if(outd[i]<ind[i])
		{
			puts("NO");
			return 0;
		}
	for(i=h+1;i<=2*h;++i)
		if(outd[i]>ind[i])
		{
			puts("NO");
			return 0;
		}
	for(i=1;i<=2*h;++i)
		p[i]=-1;
	for(i=1;i<=2*h;++i)
		for(j=1;j<=2*h;++j)
			if(g[i][j]&&find(i)!=find(j))
				p[find(i)]=find(j);
	for(i=1;i<=2*h;++i)
		if(outd[i]!=ind[i])
			ok[find(i)]=true;
	for(i=1;i<=2*h;++i)
		if(find(i)==i&&!ok[i]&&vis[i])
		{
			puts("NO");
			return 0;
		}
	puts("YES");
	return 0;
}