class SCC: def __init__(self, n): self.n = n self.g = [[] for i in range(n)] self.rg = [[] for i in range(n)] def add_edge(self, a, b): self.g[a].append(b) self.rg[b].append(a) def scc(self): def _dfs(v): used[v] = True for u in self.g[v]: if not used[u]: _dfs(u) vs.append(v) def _rdfs(v, k): used[v] = True cmp[v] = k for u in self.rg[v]: if not used[u]: _rdfs(u, k) vs = [] cmp = [-1]*self.n used = [False]*self.n for v in range(self.n): if not used[v]: _dfs(v) k = -1 used = [False]*self.n for v in reversed(vs): if not used[v]: k += 1 _rdfs(v, k) return cmp import sys import io, os sys.setrecursionlimit(10**5) input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, m = map(int, input().split()) LR0 = [] LR1 = [] for i in range(n): l, r = map(int, input().split()) LR0.append((l, r)) LR1.append((m-1-r, m-1-l)) scc = SCC(2*n) for i in range(n-1): for j in range(i+1, n): li0, ri0 = LR0[i] li1, ri1 = LR1[i] lj0, rj0 = LR0[j] lj1, rj1 = LR1[j] # 区間がかぶる場合を考える if min(ri0, rj0) >= max(li0, lj0): # ¬xi ∨ ¬xj # xi ⇒ ¬xj, xj ⇒ ¬xi scc.add_edge(i, n+j) scc.add_edge(j, n+i) if min(ri0, rj1) >= max(li0, lj1): # ¬xi ∨ xj # xi ⇒ xj, ¬xj ⇒ ¬xi scc.add_edge(i, j) scc.add_edge(n+j, n+i) if min(ri1, rj0) >= max(li1, lj0): # xi ∨ ¬xj # ¬xi ⇒ ¬xj, xj ⇒ xi scc.add_edge(n+i, n+j) scc.add_edge(j, i) if min(ri1, rj1) >= max(li1, lj1): # xi ∨ xj # ¬xi ⇒ xj, ¬xj ⇒ xi scc.add_edge(n+i, j) scc.add_edge(n+j, i) cmp = scc.scc() for i in range(n): if cmp[i] == cmp[n+i]: print('NO') exit() print('YES')