def SCC(G,N): rG=[[] for _ in range(N)] P=[] seen=[0]*N for v in range(N): for nv in G[v]: rG[nv].append(v) def dfs(G,v): seen[v]=1 for nv in G[v]: if not seen[nv]: dfs(G,nv) P.append(v) def rdfs(G,v,C): seen[v]=1 group[v]=C for nv in G[v]: if not seen[nv]: rdfs(G,nv,C) for v in range(N): if not seen[v]: dfs(G,v) seen=[0]*N group=[-1]*N C=0 for v in P[::-1]: if not seen[v]: rdfs(rG,v,C) C+=1 Size=max(group)+1 return group,Size n,m=map(int,input().split()) L,R=[],[] for _ in range(n): l,r=map(int,input().split()) L.append(l) R.append(r) G=[[] for _ in range(2*n)] for i in range(n): for j in range(i): l1,r1=L[i],R[i] l2,r2=L[j],R[j] if (l1<=l2 and l2<=r1) or (l2<=l1 and l1<=r2): G[i].append(j+n) G[j].append(i+n) l2,r2=m-R[j]-1,m-L[j]-1 if (l1<=l2 and l2<=r1) or (l2<=l1 and l1<=r2): G[i].append(j) G[j+n].append(i+n) l1,r1=m-R[i]-1,m-L[i]-1 if (l1<=l2 and l2<=r1) or (l2<=l1 and l1<=r2): G[i+n].append(j) G[j+n].append(i) l2,r2=L[j],R[j] if (l1<=l2 and l2<=r1) or (l2<=l1 and l1<=r2): G[i+n].append(j+n) G[j].append(i) group,_=SCC(G,2*n) for i in range(n): if group[i]==group[i+n]: print('NO') exit() print('YES')