#include<cstdio>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n;
unsigned long long f[150],g[150];
unsigned long long a,b;
unsigned long long search(unsigned long long m,int num);
unsigned long long search(unsigned long long m,int num)
{
if(m == 0) return 0;
if(m == f[num]) return g[num];
if(m <= f[num-1]) return search(m,num-1);
else return(g[num-1] + search(m-f[num-1], num-2));
}
int main()
{
freopen("infinit.in","r",stdin);
freopen("infinit.out","w",stdout);
f[0]=1;g[0]=0;
f[1]=1;g[1]=1;
for (int i=2;i<=92;i++)
{
f[i]=f[i-1]+f[i-2];
g[i]=g[i-1]+g[i-2];
}
scanf("%d",&n);
unsigned long long x,y;
for (int i=1;i<=n;i++)
{
scanf("%lld%lld",&a,&b);
x=search(a-1,92);
y=search(b,92);
printf("%lld\n",y-x);
}
return 0;
}