import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1]; auto g = new bool[][](n, m); foreach (i; 0..n) { auto rd2 = readln.split.to!(size_t[]), l = rd2[0], r = rd2[1] + 1; foreach (j; l..r) g[i][j] = true; } auto ci = new int[](m); foreach (i; 0..m) ci[i] = g.transversal(i).count!"a".to!int; if (m % 2 && ci[m/2+1] >= 2) { writeln("NO"); return; } foreach (i; 0..m/2) if (ci[i] + ci[$-i-1] >= 3) { writeln("NO"); return; } writeln("YES"); }