#include #include using namespace atcoder; using namespace std; using ll=long long; ll op(ll a,ll b){ return a+b; } ll e(){ return 0; } int main() { ll N; cin>>N; vector> P(N); map M; for(int i=0;i>P[i].first>>P[i].second; M[P[i].first]=M[P[i].second]=1; } int cnt=0; for(auto m:M)M[m.first]=cnt,cnt++; for(int i=0;i U(2,N*(N-1)/2); for(int t=0;t<2;t++){ segtree seg(cnt); queue Q; int x=-1; sort(P.begin(),P.end()); for(int i=0;i