#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(int i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define MOD 1000000007 #define MAX_V 200 vector graph[MAX_V]; vector rev_graph[MAX_V]; bool visited[MAX_V]; int cmp[MAX_V]; vector st; void ae(int from, int to){ graph[from].pb(to); rev_graph[to].pb(from); } void dfs(int v){ visited[v] = true; for(int i=0; i<(int)graph[v].size(); i++){ int u = graph[v][i]; if(!visited[u]){ dfs(u); } } st.push_back(v); } void rev_dfs(int v, int cnt){ visited[v] = true; for(int i=0; i<(int)rev_graph[v].size(); i++){ int u = rev_graph[v][i]; if(!visited[u]){ rev_dfs(u, cnt); } } cmp[v] = cnt; } void scc(){ memset(visited, 0, sizeof(visited)); memset(cmp, 0, sizeof(cmp)); st.clear(); for(int i=0; i>n>>m; if(n>100)return -1; if(m>1000)return -1; vector vl; vector vr; rep(i,0,n){ int l,r; cin>>l>>r; if(l>=m)return -1; if(r>=m)return -1; vl.pb(l); vr.pb(r); } rep(i,0,n){ rep(j,i+1,n){ if(vl[i]<=vr[j]&&vl[j]<=vr[i]){ ae(j,100+i); ae(i,100+j); } if(rev(vr[i])<=vr[j]&&vl[j]<=rev(vl[i])){ ae(j,i); ae(100+i,100+j); } if(vl[i]<=rev(vl[j])&&rev(vr[j])<=vr[i]){ ae(100+j,100+i); ae(i,j); } if(rev(vr[i])<=rev(vl[j])&&rev(vr[j])<=rev(vl[i])){ ae(100+i,j); ae(100+j,i); } } } scc(); rep(i,0,n){ if(cmp[i]==cmp[100+i]){ cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }