#include<bits/stdc++.h>
using namespace std;
inline void read(int &x)
{
	char c=getchar();
	x=0;
	while (c>'9'||c<'0')
		c=getchar();
	while (c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
}
const int N=10005;
int n,m,fa[N],v[N],f[N],g[N],x,y,a,b,c,d,flag;
inline int gf(int x)
{
	return fa[x]==x?x:fa[x]=gf(fa[x]);
}
int main()
{
	read(n);
	read(m);
	for (int i=1;i<=1000;++i)
		fa[i]=i;
	for (int i=1;i<=n;++i)
	{
		read(a);
		read(b);
		read(c);
		read(d);
		if (c)
			x=500-c;
		else
			x=500+a;
		if (d)
			y=500+d;
		else
			y=500-b;
		fa[gf(x)]=gf(y);
		++f[x];
		--f[y];
		v[x]=1;
	}
	flag=1;
	for (int i=1;i<500;++i)
		if (f[i]>0)
			flag=0;
	for (int i=501;i<=1000;++i)
		if (f[i]<0)
			flag=0;
	for (int i=1;i<=1000;++i)
		v[gf(i)]|=v[i];
	for (int i=1;i<=1000;++i)
		if (f[i])
			g[gf(i)]=1;
	for (int i=1;i<=1000;++i)
		if (fa[i]==i&&!g[i]&&v[i])
			flag=0;
	puts(flag?"YES":"NO");
	return 0;
}