import sys import io, os sys.setrecursionlimit(10**9) 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)) g = [[] for i in range(2*n)] rg = [[] for i in range(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] # 区間がかぶる場合を考える cnt = 0 if min(ri0, rj0) >= max(li0, lj0): # ¬xi ∨ ¬xj # xi ⇒ ¬xj, xj ⇒ ¬xi g[i].append(n+j) rg[n+j].append(i) g[j].append(n+i) rg[n+i].append(j) cnt += 1 if min(ri0, rj1) >= max(li0, lj1): # ¬xi ∨ xj # xi ⇒ xj, ¬xj ⇒ ¬xi g[i].append(j) rg[j].append(i) g[n+j].append(n+i) rg[n+i].append(n+j) if min(ri1, rj0) >= max(li1, lj0): # xi ∨ ¬xj # ¬xi ⇒ ¬xj, xj ⇒ xi g[n+i].append(n+j) rg[n+j].append(n+i) g[j].append(i) rg[i].append(j) cnt += 1 if min(ri1, rj1) >= max(li1, lj1): # xi ∨ xj # ¬xi ⇒ xj, ¬xj ⇒ xi g[n+i].append(j) rg[j].append(n+i) g[n+j].append(i) rg[i].append(n+j) cnt += 1 if cnt == 4: print('NO') exit() def dfs(v): used[v] = True for u in g[v]: if not used[u]: dfs(u) vs.append(v) def rdfs(v, k): used[v] = True cmp[v] = k for u in rg[v]: if not used[u]: rdfs(u, k) vs = [] cmp = [-1]*(2*n) used = [False]*(2*n) for v in range(2*n): if not used[v]: dfs(v) k = 0 used = [False]*(2*n) for v in reversed(vs): if not used[v]: k += 1 rdfs(v, k) for i in range(n): if cmp[i] == cmp[n+i]: print('NO') exit() print('YES')