ll@T,D[1d7];rep(T){ll@A,@B,r=Divisor(B-A,D)-1;while(r&&D[r-1]>=A)r--;wt(A