import std.conv, std.functional, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.range, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } int N, M; int[] L, R; int[][] G; int[] colors; bool dfs(int u, int c) { colors[u] = c; foreach (v; 0 .. N) { if (G[u][v] != -1) { const cc = c ^ G[u][v]; if (colors[v] == -1) { if (!dfs(v, cc)) { return false; } } if (colors[v] != cc) { return false; } } } return true; } void main() { try { for (; ; ) { N = readInt(); M = readInt(); L = new int[N]; R = new int[N]; foreach (u; 0 .. N) { L[u] = readInt(); R[u] = readInt(); } bool ans = true; G = new int[][](N, N); foreach (u; 0 .. N) { G[u][] = -1; } foreach (u; 0 .. N) { foreach (v; u + 1 .. N) { const f0 = (max(L[u], L[v]) <= min(R[u], R[v])); const f1 = (max(L[u], M - 1 - R[v]) <= min(R[u], M - 1 - L[v])); if (f0 && f1) { ans = false; } else if (f0) { G[u][v] = G[v][u] = 1; } else if (f1) { G[u][v] = G[v][u] = 1; } } } colors = new int[N]; colors[] = -1; foreach (u; 0 .. N) { if (colors[u] == -1) { ans = ans && dfs(u, 0); } } writeln(ans ? "YES" : "NO"); } } catch (EOFException e) { } }