#include using namespace std; #define int long long typedef pairpint; typedef vectorvint; typedef vectorvpint; #define pb push_back #define mp make_pair #define fi first #define se second #define all(v) (v).begin(),(v).end() #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) templateinline void chmin(T &t,U f){if(t>f)t=f;} templateinline void chmax(T &t,U f){if(t>N>>M; rep(i,N){ cin>>x[i]>>y[i]; x[i]--;y[i]--; } UF uf;uf.init(2*N); rep(i,N)rep(j,N)if(i!=j){ if((x[i]<=x[j]&&x[j]<=y[i])||(x[i]<=y[j]&&y[j]<=y[i]))uf.unite(i,j+N); int xx=M-1-x[j],yy=M-1-y[j]; if((x[i]<=xx&&xx<=y[i])||(x[i]<=yy&&yy<=y[i]))uf.unite(i,j); } rep(i,N)if(uf.same(i,i+N)){ cout<<"NO"<