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