def scc(N, G, RG): order = [] used = [0]*N group = [None]*N def dfs(s): used[s] = 1 for t in G[s]: if not used[t]: dfs(t) order.append(s) def rdfs(s, col): group[s] = col used[s] = 1 for t in RG[s]: if not used[t]: rdfs(t, col) for i in range(N): if not used[i]: dfs(i) used = [0]*N label = 0 for s in reversed(order): if not used[s]: rdfs(s, label) label += 1 return label, group def main(): N, M = map(int, input().split()) B = [list(map(int, input().split())) for _ in range(N)] g = [[] for _ in range(N*2)] def check(L1, R1, L2, R2, i, j): # AT BT rL1 = M-R1-1 rR1 = M-L1-1 f1 = f2 = False if not (R1 < L2 or R2 < L1): f1 = True if not (rR1 < L2 and R2 < rL1): f2 = True if f1 and f2: return False if f1: g[i].append(j+N) g[i+N].append(j) g[j].append(i+N) g[j+N].append(i) if f2: g[i].append(j) g[i+N].append(j+N) g[j].append(i) g[j+N].append(i+N) return True for i in range(N): L1, R1 = B[i] for j in range(i+1, N): L2, R2 = B[j] if not check(L1, R1, L2, R2, i, j): print("NO") return _, nums = scc(N*2, g, g) for i in range(N): if nums[i] == nums[i+N]: print("NO") return print("YES") main()