#include <fstream>
#define I_F "infinit.in"
#define O_F "infinit.out"
const unsigned long long M=2223372036;
const unsigned short N=200;
unsigned long long s[N]={1,2};
unsigned short n;
void GetFibonacci();
unsigned long long Fib(const unsigned long long);
int main()
{
GetFibonacci();
std::ifstream fin(I_F);
std::ofstream fout(O_F);
int q;
unsigned long long a,b;
for (fin>>q; q>0; q--)
{
fin>>a>>b;
fout<<Fib(b)-Fib(a-1)<<std::endl;
}
fin.close();
fout.close();
return 0;
}
void GetFibonacci()
{
for (n=1; s[n]<=M; n++)
s[n+1]=s[n-1]+s[n];
}
unsigned long long Fib(const unsigned long long x)
{
unsigned short t;
for (t=0; (t<n)&&(s[t]<x); t++);
if (s[t]==x)
return s[t-1];
return s[t-1]+Fib(x-s[t]);
}