#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2 * (200 + 10);

int n, H;
vector<int> adj[MAXN], rev[MAXN], vec;
int in[MAXN], out[MAXN];
bool mark[MAXN];

void dfs(int v)
{
	vec.push_back(v);
	mark[v] = true;
	for (auto i : adj[v])
		if (!mark[i])
			dfs(i);
	return;
}


int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> H;
	for (int i = 0; i < n; i++)
	{
		int a, b, c, d, v = 0, u = 0;
		cin >> a >> b >> c >> d;
		if (c)
			v += H + 1 + c;
		else
			v += a;
		if (d)
			u += d;
		else
			u += b + H + 1;
		adj[v].push_back(u);
		adj[u].push_back(v);
		in[u]++;
		out[v]++;
	}
	for (int i = 0; i < H + 1; i++)
		if (out[i] < in[i])
			return cout << "NO" << endl, 0;
	for (int i = H + 1; i < ((H + 1) << 1); i++)
		if (in[i] < out[i])
			return cout << "NO" << endl, 0;
	for (int i = 0; i < MAXN; i++)
	{
		if (!mark[i] && (in[i] + out[i]))
		{
			dfs(i);
			bool can = false;
			for (auto me : vec)
				if (in[me] != out[me])
					can = true;
			if (!can)
				return cout << "NO" << endl, 0;
			vec.clear();
		}
	}
	cout << "YES" << endl;
	return 0;
}