#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

//#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl;
#define STOP assert(false);
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif
namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}

const int MAX_V = 420;
const int Base = MAX_V / 2;

vector<int> es[MAX_V];

struct SCC{//O(V+E)
    static const int MAX_V = 1010;
    int V;
    vector<int> G[MAX_V], rG[MAX_V];
    vector<int> vs;
    bool used[MAX_V];
    int cmp[MAX_V];
    vector<vector<int> > res;


    SCC(int v) : V(v){assert(v < MAX_V);dump(v);dump(MAX_V);};
    void add_edge(int from, int to){
        G[from].push_back(to);
        rG[to].push_back(from);
    }

    void dfs(int v){
        used[v] = true;
        for(int i = 0; i < G[v].size(); i++){
            if(!used[G[v][i]]) dfs(G[v][i]);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k){
        used[v] = true;
        cmp[v] = k;
        for(int i = 0; i < rG[v].size(); i++){
            if(!used[rG[v][i]]) rdfs(rG[v][i], k);
        }
    }

    int scc(){
        memset(used, 0, sizeof(used));
        vs.clear();
        for(int v = 0; v < V; v++){
            if(!used[v]) dfs(v);
        }
        memset(used, 0, sizeof(used));
        int k = 0;
        for(int i = vs.size() - 1; i >= 0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++);
        }

        res.clear();
        res.resize(k);
        for(int i = 0; i < V; i++){
            res[cmp[i]].push_back(i);
        }
        return k;
    }
    bool check(int v, int W) {
    	return cmp[W] == cmp[v];
    }
};

int main(){
	int n, h;
	cin >> n >> h;
	vi a(n), b(n), c(n), d(n);
	rep(i, n) cin >> a[i] >> b[i] >> c[i] >> d[i];
	vi l(n), r(n);
	rep(i, n) {
		l[i] = (c[i] == 0 ? a[i] : -c[i]);
		r[i] = (d[i] == 0 ? b[i] : -d[i]);
	}
	set<int> st;
	rep(i, n) {
		int frm = (l[i] > 0 ? l[i] : Base - l[i]);
		int to = (r[i] > 0 ? Base + r[i] : -r[i]);
		st.insert(frm);
		st.insert(to);
		if(frm == to) continue;
		es[frm].pb(to);
	}
	int W = MAX_V-1;
	st.insert(W);
	vector<int> in(MAX_V), out(MAX_V);
	SCC g(MAX_V);
	rep(i, MAX_V) {
		sort(all(es[i]));
		//es[i].erase(unique(all(es[i])), es[i].end());
		int prv = -1;
		for(auto& to : es[i]) {
			if(prv != to) g.add_edge(i, to);
			prv = to;
			in[to]++;
		}
		out[i] = es[i].size();
	}
	rep(i, MAX_V) {
		if(i >= Base) {
			if(in[i] == out[i]);
			else if(in[i] < out[i]) {
				cout << "NO" << endl;
				return 0;
			}
			else {
				LINE;dump(i);dump(in[i]);dump(out[i]);dump(es[i][0]);
				g.add_edge(i, W);
			}
		}
		else {
			if(in[i] == out[i]);
			else if(in[i] > out[i]) {
				LINE;
				cout << "NO" << endl;
				return 0;
			}
			else {
				LINE;dump(i);dump(in[i]);dump(out[i]);dump(es[i][0]);
				g.add_edge(W, i);
			}
		}
	}
	g.add_edge(W-1, W);
	g.scc();
	for(auto& v : st) {
		if(!g.check(v, W)) {
			LINE;
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 4224