FIBOSUM  Fibonacci Sum
The Fibonacci sequence is defined by the following relation:
 F(0) = 0
 F(1) = 1
 F(N) = F(N  1) + F(N  2), N >= 2
Your task is very simple. Given two nonnegative integers N and M, you have to calculate the sum (F(N) + F(N + 1) + ... + F(M)) mod 1000000007.
Input
The first line contains an integer T (the number of test cases). Then, T lines follow. Each test case consists of a single line with two nonnegative integers N and M.
Output
For each test case you have to output a single line containing the answer for the task.
Example
Input: 3 0 3 3 5 10 19 Output: 4 10 10857
Constraints
 T <= 1000
 0 <= N <= M <= 10^{9}
hide comments
prash8830:
20220714 08:51:03
Fibonacci Sequence Sum Property :


hitesh21:
20220127 07:12:36
Mod can decrease the value of large interger values


ram_321:
20211201 10:06:58
everyone is telling matrix exponentiation but no one is actually explaining the idea behind the summation stuff.


azeez72:
20210824 20:20:38
I like cock Last edit: 20210825 00:52:28 

flashshadow:
20210506 06:49:36
I did matrix exponentiation upto n and then I multiply by matrix power of 2 each time until i reach m, I'm getting the correct answer but time limit is exceeded. Anyone have ideas for removing the stepping by 2 factor? I guess that should be cause. thanks 

yash_ver:
20210211 12:48:21
!!IMPORTANT!!


kokonut_hustle:
20201202 15:46:22
Nice problem for matrix exponentiation 

yzs:
20200927 09:36:39
@ks_r 7 Last edit: 20200927 09:40:50 

roshan_84ya:
20200921 21:08:28
x1 = ((a[0][0]*b[0][0])%mod + (a[0][1]*b[1][0])%mod)%mod is this is the correct way of modulo in matrix multiplication 

ks_r:
20200727 08:52:50
can any one tell what should be ans if i/p is

Added by:  David Gómez 
Date:  20101204 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  My Own 