import std.bigint,std.stdio,std.string;int M=10^^9+7,S=4901961,j;long y,z,e;void i(long x){y=1;for(e=M-2;e;e/=2,x=x*x%M)if(e&1)y=y*x%M;}void f(int n){if(n>M/2){f(M-1-n);z.i;z=n%2?y:M-y;}else{j=n%S;if(j>S-j){for(z=1,j=S-j;j--;)z=z*++n%M;z.i;}else{for(y=1;j--;)y=y*n--%M;}for(z=0,j=5;j--;)z=z<<6|`! R@I>DB[^^N%4Z>P@'#$S8:]:0(D4G@_A7Y>F!E&$[;(=@B*[<5V?*9'EAWK(\4Y:;\Z#.^F#BR_!,%!S1VP!G-#A&.P#GUMC5:,:TM1Z0ET)0Q3S^+/.RW_NTU$ 0JP$81PH:RKR'0@T/U!WR@*W$@K/>&I>?$RX->C["IY(\[[P_1QX-##W.G?&.!F\A(DG.A^_)T2%W- (K_'< 7MZ*4&2 S5ZM(EIC6(.4)?D*/K2E0 WMY+--1=';CGN74&Z.OIU*SSN1V)XNEO)D=O.1=7]EE6U(04+Z18Z90RT+,(XZ<1#Q-;HLH*2CSUX*7-30)#7L;M7YP8@S\:Q21]C[\^O+0U^/CA4:WR!2/M#=_Q4EYY-R6>4R,Y,7[5.X#_W6=(-+-:SN)%G@]>/!N?..RWAU,O[T^V7"P+#WVPZV79%3U?@G7Q?V8"VE%,A3O\2+SGGG=4`[n/S*5+j]-32;z=z*y%M;}}void main(){for(auto t=readln.chomp.BigInt;t--;){auto s=readln.split;BigInt r=s[0],l=s[1];r+=1-l;l=r-l;writeln(l<0||l/M