#include <bits/stdc++.h>
using namespace std;
const int maxn = 444;
int uf[maxn], has[maxn];
int in[maxn], out[maxn];
int find(int x){
	if(x == uf[x]) return x;
	return uf[x] = find(uf[x]);
}
int main(){
	iota(uf, uf + maxn, 0);
	int n, h; cin >> n >> h;
	for(int i = 0; i < n; i++){
		int a, b, c, d; cin >> a >> b >> c >> d;
		int x = (c == 0) ? (a + 200) : c;
		int y = (d == 0) ? b : (d + 200);
		out[x]++;
		in[y]++;
		uf[find(x)] = find(y);		
	}
	for(int i = 1; i <= h; i++){
		if(out[i] > in[i]) return !printf("NO\n");
		if(in[i] > out[i]) has[find(i)] = 1;
	}
	for(int i = 200 + 1; i <= 200 + h; i++){
		if(in[i] > out[i]) return !printf("NO\n");
		if(in[i] < out[i]) has[find(i)] = 1;
	}
	for(int i = 1; i <= h; i++){
		if((in[i] || out[i]) && !has[find(i)]) return !printf("NO\n");
		if((in[200+i] || out[200+i]) && !has[find(200+i)]) return !printf("NO\n");
	}
	printf("YES\n");
	return 0;
}
