#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair P; typedef tuple T; inline bool cheak(ll x, ll y, ll xMax, ll yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; } inline ll toInt(string s) { ll v; istringstream sin(s); sin >> v; return v; } template inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } template inline T sqr(T x) { return x*x; } #define For(i,a,b) for(ll (i) = (a);i < (b);(i)++) #define rep(i,n) For(i,0,n) #define rFor(i,a,b) for(ll (i) = (a-1);i >= (b);(i)--) #define rrep(i,n) rFor(i,n,0) #define clr(a) memset((a), 0 ,sizeof(a)) #define mclr(a) memset((a), -1 ,sizeof(a)) #define all(a) (a).begin(),(a).end() #define sz(a) (sizeof(a)) const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 }; const ll mod = 1e9 + 7; const ll INF = 1e9 + 2; int n, m; bool base[5000]; void reverse_LR(int &L,int &R){ int r = m - L - 1; int l = (m - R - 1); L = l, R = r; } bool ok(int L,int R){ for (int j = L; j <= R; j++){ if (base[j])return false; } return true; } int main(){ cin >> n >> m; rep(i, n){ int L, R; cin >> L >> R; if (ok(L, R) == false){ reverse_LR(L, R); if (ok(L, R) == false){ cout << "NO" << endl; return 0; } } for (int j = L; j <= R; j++){ base[j] = true; } } cout << "YES" << endl; return 0; }