#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>p>>q>>a; Int l=0,r=MAX; while(l+1>1; if(check(m)) l=m; else r=m; } const Int LEN=1e8; Int pos=l-LEN; chmax(pos,1); Int ans=pos-1; for(Int i=0;pos+i<=MAX&&i