#include<cstdio>
#include<cstring>
#define retrun return
#define cpnst const
int CT[444][444],DEG[444],SZ[444],Lm=401;
class UFS
{
	int Fa[1111];
	public:
	void init(){for(register int i=1;i<=1000;i++)Fa[i]=i;}
	int rt(int x){return Fa[x]^x?Fa[x]=rt(Fa[x]):x;}
	bool merge(int x,int y){return x=rt(x),y=rt(y),Fa[x]=y,x^y;}
}U;
void rd()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(c)a=-c;if(d)b=d;else b=-b;
	U.merge(a+201,b+201),CT[a+201][b+201]++,
	DEG[a+201]++,DEG[b+201]--,SZ[a+201]++,SZ[b+201]++;
}
int UNB[11111];
void cover(int x)
{UNB[U.rt(x)]=1;}
int main()
{
	register int i;
	int n;
	scanf("%d%*d",&n),U.init();
	for(i=1;i<=n;i++)rd();
	for(i=-200;i<=200;i++)
	{
		if(i<0&&DEG[i+201]>0)return puts("NO"),0;
		if(i>0&&DEG[i+201]<0)return puts("NO"),0;
	}for(i=1;i<=Lm;i++)
		if(DEG[i])cover(i);
	for(i=1;i<=Lm;i++)
		if(SZ[i])
			if(!UNB[U.rt(i)])return puts("NO"),0;
	puts("YES");
}
/*
Just go for it.
*/