#include using namespace std; #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define spa << " " << #define lfs <= (ll)(m); i--) typedef long long ll; typedef long double ld; const ll MOD = 1e9+7; //const ll MOD = 998244353; const ll INF = 1e18; using P = pair; template void chmin(T &a,T b){if(a>b)a=b;} template void chmax(T &a,T b){if(a void ans(bool x,T1 y,T2 z){if(x)cout< void debug(vector>v,ll h,ll w){for(ll i=0;iv,ll h,ll w){for(ll i=0;i void debug(vectorv,ll n){cout< vector>vec(ll x, ll y, T w){ vector>v(x,vector(y,w));return v;} ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;} template void emp(map&m, T x){m.emplace(x,0).first->second++;} vectordx={1,0,-1,0,1,1,-1,-1}; vectordy={0,1,0,-1,1,-1,1,-1}; struct SCC{ ll n; vector>G,Gr; vectorindex;//各ノードが属する強連結成分の番号 vectorret;//dfsに使う SCC(vector>g):G(g),n(g.size()){ index.assign(n,-1LL); build(); } void build(){ Gr.assign(n,vector()); for(ll i=0;ioutput(){return index;}; }; int main(){ cin.tie(NULL); ios_base::sync_with_stdio(false); ll res=0,res1=INF,res2=-INF,buf=0; bool judge = true; ll n,m;cin>>n>>m; vector>g(2*n); vectorl(n),r(n); rep(i,0,n)cin>>l[i]>>r[i]; rep(i,0,n)rep(j,i+1,n){ if(l[i]<=r[j]&&r[i]>=l[j]){ g[i].PB(j+n); g[j].PB(i+n); } if(m-1-l[i]<=l[j]&&m-1-r[i]>=r[j]){ g[i+n].PB(j+n); g[j+n].PB(i+n); } if(l[i]<=m-1-l[j]&&r[i]>=m-1-r[j]){ g[i].PB(j); g[j].PB(i); } if(m-1-r[i]<=m-1-l[j]&&m-1-l[i]>=m-1-r[j]){ g[i+n].PB(j); g[j+n].PB(i); } } SCC scc(g); auto idx=scc.output(); rep(i,0,n){ if(idx[i]==idx[i+n])judge=false; } ans2(judge); return 0; }