#define V {return x;} ll segtree_rh_merge(ll x,ll y)V;ll segtree_rh_apply(ll x,ll y)V;ll segtree_rh_compose(ll x,ll y)V;{ll@N,@o,@X[N],@T,@W[T*2],M=548;mapZ;rep[X](x,N)Z[x];rep[W](w,T*2)Z[w];ll s=0;for(auto i=Z.begin(),e=Z.end();i!=e;i++)i->second=s++;rep[X](x,N)x=Z[x];rep[W](w,T*2)w=Z[w];segtree_rhA;A.malloc(s);A.setN(s,0,0);rep(t,T)A.change(W[t*2],W[t*2+1]+1,t+2);rep[X](x,N)wt(A.get(x,x+1)-1);}