#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>n>>l; set sx,sy; for(Int i=0;i>x; sx.emplace(x); } for(Int i=0;i>y; sy.emplace(y); } Int time=0; while(!sx.empty()){ { Int t=time%l; auto it=sx.upper_bound(t); if(it==sx.end()){ time+=l-t; time+=*sx.begin(); sx.erase(sx.begin()); }else{ time+=*it-t; sx.erase(it); } } if(sx.empty()){ Int t=time%l; Int u=*sy.begin(); if(t