#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(int i=0; i<(n); i++) int N,M; struct L{ int l, r; bool rev, fix; L(){ rev = false; fix = false; } int le() { return (rev ? M - 1 - r : l); } int ri() { return (rev ? M - 1 - l : r); } }; signed main() { cin >> N >> M; vector Ls(N); REP(i,N) { cin >> Ls[i].l >> Ls[i].r; } int k = 0; bool ok = true; while(k <= M/2) { vector hasi; vector hasr; REP(i,N) { L l = Ls[i]; if (l.le() <= k && k <= l.ri()) hasi.push_back(i); if (M-1-l.ri() <= k && k <= M-1-l.le()) hasr.push_back(i); } // 真ん中は別処理 if (M%2==1 && k==M/2) { if (hasi.size() >= 2) { ok = false; break; } } else if (hasi.size() + hasr.size() >= 3) { ok = false; break; } if (hasi.size() == 2) { bool hasrev = false; for (auto&& j : hasi) { if (Ls[j].fix == false && Ls[j].rev == false) { Ls[j].rev = true; hasrev = true; break; } } if (!hasrev) ok = false; } else if (hasr.size() == 2) { bool hasrev = false; for (auto&& j : hasr) { if (Ls[j].fix == false && Ls[j].rev == false) { Ls[j].rev = true; hasrev = true; break; } } if (!hasrev) ok = false; } if (hasi.size() + hasr.size() == 2) { for (auto&& j : hasi) { Ls[j].fix = true; } for (auto&& j : hasr) { Ls[j].fix = true; } } if (!ok) break; k++; } cout << (ok ? "YES" : "NO") << endl; return 0; }