import std.bigint,std.stdio,std.string;enum M=10^^9+7,S=M/91;long y,z,e,j;void i(){for(y=1,e=M-2;e;e/=2,z=z*z%M)y=e%2?y*z%M:y;}void f(long n){if(n>M-n)f(M-1-n),i,z=n%2?y:M-y;else{if(n%S<$F!@]:MBF,4;(Q_VB<*YW2T#X&!N&9K!T7J$^9U)=S5J+8==&)AS,YR6S OV])'I9'F65VK9'&@+9I,?NV3>O;=(\310BY$4T,I8%#%"#>G><`[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-=l-1;l=r-l;writeln(l<0||l/M