#include <iostream>
#include <cstdio>
using namespace std;
const int maxn=100;
long long f[100],g[100];
int digui(long long a,int dep)
{
if (a==0) return 0;
if (a==f[dep]) return g[dep];
if (a<=f[dep]) return digui(a,dep-1);
}
int main()
{
freopen ("infinit.in","r",stdin);
freopen ("infinit.out","w",stdout);
long long a,b,ans,n,i;
f[1]=g[2]=g[1]=1;
f[2]=2;
for (i=3;i<maxn;i++)
{
f[i]=f[i-1]+f[i-2];
g[i]=g[i-1]+g[i-2];
}
cin>>n;
for (i=1;i<=n;i++)
{
cin>>a>>b;
ans=digui(b,maxn-1)-digui(a-1,maxn-1);
cout<<ans;
}
return 0;
}