ll@t; rep(t){ ll@x,@a,@b; sortE(a,b); wt(a/gcd(a,b)*2-x/b-(x-1)/b+((x+1)/+a*a<(x+1)/+b*b)); }