#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
const int N=405;
int n,m=401;
int fa[N],in[N],out[N],cnt[N],f[N];
int _(int k){
	if (k<0)
		return 401+k;
	else
		return k;
}
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
int main(){
	for (int i=1;i<=m;i++)
		fa[i]=i;
	n=read();
	read();
	while (n--){
		int a=read(),b=read(),c=read(),d=read();
		int x=c?-c:a;
		int y=d?d:-b;
		x=_(x),y=_(y);
		fa[getf(x)]=getf(y);
		in[y]++,out[x]++;
	}
	for (int i=1;i<=m;i++){
		if (!in[i]&&!out[i])
			continue;
		cnt[getf(i)]++;
		if (in[i]!=out[i])
			f[getf(i)]=1;
	}
	for (int i=1;i<=200;i++)
		if (out[i]<in[i]||in[401-i]<out[401-i])
			return puts("NO"),0;
	for (int i=1;i<=m;i++)
		if (cnt[i]&&!f[i])
			return puts("NO"),0;
	puts("YES");
	return 0;
}