#include<stdio.h>
//if-uri %I64d
int val1,val2;
long long sum,x1,y1,x2,y2,cx1,cx2;
long long fib[75]={0,1,2LL,3LL,5LL,8LL,13LL,21LL,34LL,55LL,89LL,144LL,233LL,377LL,610LL,987LL,1597LL,2584LL,4181LL,6765LL,
10946LL,17711LL,28657LL,46368LL,75025LL,121393LL,196418LL,317811LL,514229LL,832040LL,1346269LL,2178309LL,3524578LL,
5702887LL,9227465LL,14930352LL,24157817LL,39088169LL,63245986LL,102334155LL,165580141LL,267914296LL,433494437LL,701408733LL,
1134903170LL,1836311903LL,2971215073LL,4807526976LL,7778742049LL,12586269025LL,20365011074LL,32951280099LL,53316291173LL,86267571272LL,
139583862445LL,225851433717LL,365435296162LL,591286729879LL,956722026041LL,1548008755920LL,2504730781961LL,4052739537881LL,6557470319842LL,
10610209857723LL,17167680177565LL,27777890035288LL,44945570212853LL,72723460248141LL,117669030460994LL,
190392490709135LL,308061521170129LL,498454011879264LL,688846502588399LL,1187300514467663LL,1876147017056062LL};
void search(long long m1,long long m2)
{
int i,st,dr,m;
st=1,dr=74;
while(st+2<dr)
{
m=(st+dr)/2;
if (fib[m]>m1)
dr=m;
else st=m;
}
if (m1==0)
val1=1;
for (i=st;i<=dr;++i)
if (m1>fib[i-1] && m1<=fib[i])
{val1=i;break;}
st=1,dr=74;
while(st+2<dr)
{
m=(st+dr)/2;
if (fib[m]>m2)
dr=m;
else st=m;
}
for (i=st;i<=dr;++i)
if (m2>=fib[i] && m2<fib[i+1])
{val2=i;break;};
}
int main()
{
int n,i,j;
freopen("fibo3.in","r",stdin);
freopen("fibo3.out","w",stdout);
scanf("%d",&n);
for (i=1;i<=n;++i)
{
sum=0;
scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
search(x1+y1,x2+y2);
for (j=val1;j<=val2;++j)
{
if (x1+y2>=fib[j])
cx1=x1;
else
cx1=fib[j]-y2;
if (x2+y1>=fib[j])
cx2=fib[j]-y1;
else
cx2=x2;
if (cx2>cx1)
sum+=cx2-cx1+1;
else
sum+=cx1-cx2+1;
}
printf("%lld\n",sum);
}
return 0;
}