import sys readline = sys.stdin.readline write = sys.stdout.write 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 order.reverse() for s in order: if not used[s]: rdfs(s, label) label += 1 return label, group def solve(): N, M = map(int, readline().split()) S = [tuple(map(int, readline().split())) for i in range(N)] G = [[] for i in range(2*N)] RG = [[] for i in range(2*N)] def add_edge(i, neg_i, j, neg_j): if neg_i: i0 = i+N; i1 = i else: i0 = i; i1 = i+N if neg_j: j0 = j+N; j1 = j else: j0 = j; j1 = j+N G[i1].append(j0); RG[j0].append(i1) G[j1].append(i0); RG[i0].append(j1) for i in range(N): li, ri = S[i] for j in range(i+1, N): lj, rj = S[j] if (li <= rj and lj <= ri): add_edge(i, 0, j, 0) add_edge(i, 1, j, 1) if (li <= M-1-lj and M-1-rj <= ri): add_edge(i, 0, j, 1) add_edge(i, 1, j, 0) label, group = scc(2*N, G, RG) ok = 1 for i in range(N): if group[i] == group[i+N]: ok = 0 break if ok: write("YES\n") else: write("NO\n") solve()