#include #include #include #include //#include #include #include #include #include #include //#include #include #include #include //#include #include #include //#include #include #include #include #include const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; const int MAXN = 2020; const int MAXM = 4020; int L[MAXN], R[MAXN]; int N, M; bool solve(const vector& walls) { int l = 0, r = M-1; for (auto p : walls) { if (p.first >= l) { if (p.second > r) { return false; } l = p.second+1; } else if (M-p.first-1 <= r) { if (M-p.second-1 < l) { return false; } r = M-p.second-1; } else return false; } return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; vector walls; for (int i = 0; i < N; i++) { cin >> L[i] >> R[i]; if (L[i] <= M-R[i]-1) walls.emplace_back(L[i], R[i]); else walls.emplace_back(M-R[i]-1, M-L[i]-1); } sort(walls.begin(), walls.end()); cout << (solve(walls) ? "YES" : "NO") << endl; return 0; }