#include<bits/stdc++.h>
using namespace std;
const int maxn = 440;
int n, c, d, l, r, deg[maxn], vis[maxn];
vector<int> g[maxn];
void add_edge(int l, int r) {
	l += maxn/2, r += maxn/2;
	deg[l]++, deg[r]--;
	g[l].push_back(r);
}
void dfs(int v) {
	vis[v] = 1;
	for(auto &i : g[v]) if(!vis[i]) dfs(i);
}
bool check() {
	dfs(0);
	for(int i = 0; i < maxn; i++) if(g[i].size() && (!vis[i] || deg[i])) return false;
	return true;
}
int main() {
	cin >> n >> r;
	map<int, int> L, R;
	while(n--) {
		cin >> l >> r >> c >> d;
		if(c > 0) l = -c;
		if(d > 0) r = -d;
		add_edge(l, -r);
		if(l < 0) R[-l]--;
		else L[l]++;
		if(r < 0) L[-r]--;
		else R[r]++;
	}
	for(auto i : L) {
		if(i.second < 0) return cout << "NO", 0;
		while(i.second--) add_edge(-220, i.first);
	}
	for(auto i : R) {
		if(i.second < 0) return cout << "NO", 0;
		while(i.second--) add_edge(-i.first, -220);
	}
	cout << (check()?"YES":"NO");
}
