/*    ∫ ∫ ∫    ノヽ   (_  )  (_    ) (______ )  ヽ(´・ω・)ノ     |  /    UU */ #pragma region macro #include typedef long long int64; using namespace std; using P = pair; typedef vector vi; const int MOD = (int)1e9 + 7; const int64 INF = 1LL << 62; const int inf = 1<<30; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b ostream& operator<<(ostream& os, const vector &V){ int N = V.size(); REP(i,N){ os << V[i]; if (i!=N-1) os << " "; } os << "\n"; return os; } template ostream& operator<<(ostream& os, pair const&P){ os << "("; os << P.first; os << " , "; os << P.second; os << ")"; return os; } template ostream& operator<<(ostream& os, set &S){ auto it=S.begin(); while(it!=S.end()){ os << *it; os << " "; it++; } os << "\n"; return os; } template ostream& operator<<(ostream& os, deque &q){ for(auto it=q.begin();it> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)}; #pragma endregion //fixed< topological_idx; //属する強連結成分のトポロジカル順序 vector visited; vector> edge, edge_rev; vector post_order; int N; int scc_size = 0; //強連結成分の数 //O(N+M) StronglyConnectedComponents(vector>& edge):edge(edge){ N = edge.size(); edge_rev.resize(N); for(int v=0;v> build_graph(){ vector> new_edge(N); for(int i=0;i rev(pair& A){ return mp(M-1-A.second, M-1-A.first ); } bool is_cross(pair& A, pair& B){ return min(A.second,B.second) >= max(A.first,B.first); } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; vector> LR; int l,r; REP(i,N){ cin >> l >> r; LR.emplace_back(l,r); } pair A,B,A_rev,B_rev; vector> edge(2*N); REP(i,N){ A = LR[i]; A_rev = rev(A); for(int j=i+1;j