#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a; set

sp; // [l, r) void add(Int l,Int r){ assert(l!=r); if(sp.empty()){ sp.emplace(l,r); return; } while(1){ auto it=sp.upper_bound(P(l,l)); if(it==sp.begin()) break; it--; Int pl,pr; tie(pl,pr)=*it; assert(pl>n; vector a(n),b(n),c(n); for(Int i=0;i>a[i]>>b[i]>>c[i]; vector l(n),r(n),v(n),w(n); for(Int i=0;i dp; for(Int t=0;t<60;t++){ for(Int i=0;i nx; for(auto &st:dp){ Int x=st.first; for(auto p:st.second.sp){ // cout<>1; Int l1=l0-(p.first&1); Int r0=(p.second+1)>>1; Int r1=r0-(p.second&1); assert(p.first<=l0*2&&p.second<=r0*2); assert(p.first<=l1*2+1&&p.second<=r1*2+1); assert(p.first>l0*2-2&&p.second>r0*2-2); assert(p.first>l1*2-1&&p.second>r1*2-1); //cout<<":"<first)+1==(it->second)); Int x=p.first+(1LL<<60)*(it->first); cout<