#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,h,deg[410],cnt;
bool flag[410];
struct edge
{
    int v;
    edge *nxt;
} pool[100100],*tp=pool,*fst[410];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

void addedge(int u,int v)
{
    *tp=(edge){v,fst[u]},fst[u]=tp++;
    ++deg[u],--deg[v];
}

void dfs(int x)
{
    if (flag[x])
        return;
    flag[x]=1;
    for (edge *i=fst[x]; i; i=i->nxt)
        ++cnt,dfs(i->v);
}

bool check()
{
    repu(i,1,n)
    {
        int a=getint(),b=getint(),c=getint(),d=getint();
        int u=c?c:h+a,v=d?h+d:b;
        addedge(u,v);
    }
    repu(i,1,h*2)
    {
        if (deg[i]>0)
            if (i>h)
                dfs(i);
            else
                return 0;
        if (deg[i]<0 && i>h)
            return 0;
    }
    return cnt==n;
}

int main()
{
    scanf("%d%d",&n,&h);
    puts(check()?"YES":"NO");
    return 0;
}