// (⁠◕⁠ᴗ⁠◕⁠✿⁠) #include // #include // using namespace atcoder; // using mint = modint1000000007; // using mint = modint998244353; // using vmint = vc;using vvmint = vc; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define srep(i, s, n) for (int i = s; i < n; i++) #define drep(i, n) for (int i = n; i >= 0; i--) #define dsrep(i, s, n) for (int i = s; i >= n; i--) #define len(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl using namespace std; template using vc = vector; template using vv = vc>; using vi = vc;using vvi = vv; using vvvi = vv; using ll = long long;using vl = vc;using vvl = vv; using vvvl = vv; using ld = long double; using vld = vc; using vvld = vc; using vvvld = vc; using uint = unsigned int; using ull = unsigned long long; using pii = pair; const double pi = 3.141592653589793; const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3f; // const int mod = 1000000007; const int mod = 998244353; inline bool inside(long long y, long long x, long long H, long long W) {return 0 <= y and y < H and 0 <= x and x < W; } struct phash{ inline size_t operator()(const pair & p) const{ const auto h1 = hash()(p.first); const auto h2 = hash()(p.second); return h1 ^ (h2 << 1); } }; struct twosat{ public : twosat(int n) : nn(n){ _n = 2 * nn; group = vi(_n, -1); order = vi(); order.clear(); g = vvi(_n); rg = vvi(_n); label = 0; answer = vc(nn); } void add_edge(int u, int v){ g[u].push_back(v); rg[v].push_back(u); } void dfs(int s){ used[s] = true; for (auto t : g[s]){ if (!used[t]) dfs(t); } order.push_back(s); } void rdfs(int s, int color){ group[s] = color; nused[s] = true; for (auto t : rg[s]){ if (!nused[t]) rdfs(t, color); } } void scc(){ used = vc(_n); nused = vc(_n); rep(i, _n){ if (!used[i]) dfs(i); } drep(i, len(order) - 1){ if (!nused[order[i]]){ rdfs(order[i], label); label++; } } } void add(int i, bool f, int j, bool g){ add_edge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0)); add_edge(2 * j + (g ? 0 : 1), 2 * i + (f ? 1 : 0)); } bool judge(){ scc(); rep(i, nn){ if (group[2 * i] == group[2 * i + 1]) return false; answer[i] = group[2 * i] < group[2 * i + 1]; } return true; } vc restore(){ return answer; } private : int _n, nn, label; vi order, group; vvi g, rg; vc used, nused, answer; }; int main(){ int N, M; cin >> N >> M; vc> pincs; rep(i, N){ int l, r; cin >> l >> r; pincs.push_back({l, r}); } twosat ts(N); rep(j, N) rep(i, j){ auto [l1, r1] = pincs[i]; auto [l2, r2] = pincs[j]; if (max(l1, l2) <= min(r1, r2)){ ts.add(i, 0, j, 0); } if (max(l1, M - 1 - r2) <= min(r1, M - 1 - l2)){ ts.add(i, 0, j, 1); } if (max(M - 1 - r1, l2) <= min(M - 1 - l1, r2)){ ts.add(i, 1, j, 0); } if (max(M - 1 - r1, M - 1 - r2) <= min(M - 1 - l1, M - 1 - l2)){ ts.add(i, 1, j, 1); } } if (ts.judge()) cout << "YES" << endl; else cout << "NO" << endl; }