#include <bits/stdc++.h>
using std::cerr;
using std::endl;

const int N = 1e5 + 233;

int n, h, A[N], B[N], C[N], D[N];
int out[N], in[N], fa[N], vis[N];

int find(int x) {
  return x == fa[x] ? x : fa[x] = find(fa[x]);
}

inline bool check() {
  for (int i = 0; i < h; ++i)
    if (in[i] > out[i]) return 0;
  for (int i = 1; i <= h; ++i)
    if (in[i + h] < out[i + h]) return 0;
  for (int i = -h; i <= h; ++i)
    if ((!in[i + h] && !out[i + h]) || (in[i + h] != out[i + h]))
      vis[find(i + h)] = 1;
  for (int i = -h; i <= h; ++i)
    if (!vis[find(i + h)]) return 0;
  return 1;
}

int main() {
  scanf("%d %d", &n, &h);
  for (int i = 0; i <= h * 2 + 5; ++i)
    fa[i] = i;
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d %d %d", A + i, B + i, C + i, D + i);
    int x = C[i] == 0 ? h - A[i] : h + C[i];
    int y = D[i] == 0 ? h + B[i] : h - D[i];
    ++out[x], ++in[y];
    x = find(x), y = find(y);
    if (x != y) fa[x] = y;
  }
  puts(check() ? "YES" : "NO");
  return 0;
}

