#include using namespace std; using i64 = int64_t; using vi = vector; using vvi = vector; int main() { int n, m; cin >> n >> m; vvi adj(n * 2); using ii = pair; vector lr; for (int i = 0; i < n; i++) { int l, r; cin >> l >> r; lr.push_back(ii(l, r)); adj[i].push_back(i + n); adj[i + n].push_back(i); } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { ii a = lr[i], b = lr[j]; if (a > b) swap(a, b); if (b.first <= a.second) { adj[i].push_back(j); adj[j].push_back(i); adj[i + n].push_back(j + n); adj[j + n].push_back(i + n); } b = ii(m - 1 - b.second, m - 1 - b.first); if (a > b) swap(a, b); if (b.first <= a.second) { adj[i + n].push_back(j); adj[j].push_back(i + n); adj[i].push_back(j + n); adj[j + n].push_back(i); } } } int ok = 1; vi color(2 * n, -1); unordered_set unvisited; for (int i = 0; i < 2 * n; i++) { unvisited.insert(i); } function dfs = [&](int v, int c) { if (color[v] == -1) { unvisited.erase(v); color[v] = c; for (int s: adj[v]) { dfs(s, !c); } } else { if (color[v] != c) { ok = 0; } } }; while (unvisited.size()) { int t = *unvisited.begin(); dfs(t, 0); } cout << (ok ? "YES" : "NO") << endl; }