// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// contancer library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class K, class T>
ostream& operator<<(ostream& os, map<K, T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class T>
ostream& operator<<(ostream& os, queue<T> q) {
    os << "[";
    while (!q.empty()) {
        os << q.front() << ",";
        q.pop();
    }
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, priority_queue<T> q) {
    os << "{";
    while (!q.empty()) {
        os << q.top() << ",";
        q.pop();
    }
    return os << "}";
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// mt19937 mt(ll(time(0)));

template <class T>
vector<T> Vec(size_t l, T v) { return vector<T>(l, v); }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <typename T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

template <typename T, typename U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

template <typename T, typename U>
T mpow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * b % MOD;
        n >>= 1;
        b = b * b % MOD;
    }
    return ret;
}

void fail() {
    cout << "NO" << endl;
    exit(0);
}

class QuickFind {
public:
    QuickFind(int N) : V_NUM(N) {
        par.resize(V_NUM);
        iota(par.begin(), par.end(), 0);
        group.resize(V_NUM);
        for (int i = 0; i < N; ++i) group[i] = {i};
    }

    int find(int v) {
        return par[v] == v ? v : par[v] = find(par[v]);
    }

    void merge(int u, int v) {
        u = find(u);
        v = find(v);
        if (u == v) return;
        if (group[u].size() < group[v].size()) swap(u, v);

        par[v] = u;
        copy(group[v].begin(), group[v].end(), back_inserter(group[u]));
        group[v].erase(group[v].begin(), group[v].end());
    }

    int V_NUM;
    vector<vector<int>> group;
    vector<int> par;
};

int main() {
    int N, H;
    cin >> N >> H;

    vector<int> in(H * 2, 0), out(H * 2, 0);
    QuickFind qf(H * 2);
    for (int i = 0; i < N; ++i) {
        int A, B, C, D;
        cin >> A >> B >> C >> D;
        --A, --B, --C, --D;

        int from, to;
        if (C < 0) {
            from = A;
        } else {
            from = C + H;
        }

        if (D < 0) {
            to = B + H;
        } else {
            to = D;
        }

        ++out[from];
        ++in[to];
        qf.merge(from, to);
    }
    cerr << in << endl;
    cerr << out << endl;

    cerr << qf.group << endl;
    for (auto& g : qf.group) {
        if (g.empty()) continue;
        if (g.size() == 1) {
            if (in[g[0]] != 0) fail();
        } else {
            bool judge = false;
            for (auto i : g) {
                int d = out[i] - in[i];
                if ((i < H && d < 0) || (i >= H && d > 0)) fail();
                if (i < H && d > 0) judge = true;
            }
            if (!judge) fail();
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256