#include <bits/stdc++.h>

using namespace std;

const int Nmax = 500;

int n, H, i, x, y, A, B, C, D, grad[Nmax];
bool ok, used[Nmax];
vector<int> v[Nmax];

void dfs(int node)
{
    used[node] = 1;
    ok |= (grad[node] != 0);
    for(auto it : v[node])
        if(!used[it]) dfs(it);
}

int main()
{
   // freopen("input", "r", stdin);

    cin >> n >> H;
    for(i=1; i<=n; ++i)
    {
        cin >> A >> B >> C >> D;
        x = (C ? C : A + H);
        y = (D ? D + H : B);

        v[x].push_back(y);
        v[y].push_back(x);
        ++grad[x]; --grad[y];
    }

    ok = 1;
    for(i=1; i<=H && ok; ++i) ok &= (grad[i] <= 0);
    for(; i<= 2*H && ok; ++i) ok &= (grad[i] >= 0);

    for(i=1; i <= 2 * H && ok; ++i)
        if(!used[i] && v[i].size())
        {
            ok = 0;
            dfs(i);
        }

    cout << (ok ? "YES" : "NO") << '\n';

    return 0;
}
