#include<iostream>
#include<stdio.h>
using namespace std;
#define k 1000LL
int fib(int n)
{
int c,first=0,second=1,next;
for ( c = 0 ; c <=n; c++ )
{
if ( c <= 1 )
next = c;
else
{
next = first + second;
first = second;
second = next;
}
}
return next;
}
int main() {
int n,m,t,sum=0;
scanf("%d",&t);
while(t--)
{
sum=0;
scanf("%d%d",&m,&n);
for(int i=m;i<=n;i++)
{
sum+=fib(i);
}
sum=sum%k;
cout<<sum<<endl;
}
return 0;
}
Input example
2
0 3
3 5
constraints -
k= 10^9+7
1<=n<=50
1<=m<=10^9