import std.bigint,std.stdio,std.string;enum M=10^^9+7,S=M/99;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%SE3C1 B>NVHP]NCD2RB=UQ!5ORB<@2(K/0;W7$I!R,>)#S!$_J36_#[(D!UV9,"GZ"7"QKX1M:Z<`[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