#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>N>>M; priority_queue > Q; FOR(i,N) { cin>>L[i]>>R[i]; } int left=0; FOR(i,N) { int y=-1; FOR(x,N) if(vis[x]==0) { if(M-1-R[x]L[x]) { L[x]=M-1-L[x]; R[x]=M-1-R[x]; swap(L[x],R[x]); } if(left>L[x]) return _P("NO\n"); if(y==-1 || L[x]