New Sequence

0

0 votes
Matrix Exponentiation, Hard, Approved, Recruit
Problem

You are given a sequence whose first and the second elements are 0 and 1 respectively.
The ith element of sequence is given by:

bi = (1)i+1 * [|bi1|+|bi2|]

where |K| represents the absolute value of K. If the element is very large, take modulo with 109+7.
Write a program to find the sum of the sequence having indexes between L and R (L and R inclusive). If the answer is very large, output it as modulo 109+7. It is guaranteed that result will always be positive.

Input Format
First line: T, the number of test cases
Next T lines: L and R

Output Format
For each test case, output an integer which is the sum of all elements having indexes between L and R of the given sequence.

Input Constraints:
1T104
0L1015
LR1015
0-based indexing is followed.

Sample Input
2
2 3
1 1
Sample Output
1
1
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The sequence is: 0,1,-1,2. The sum from index 2 to 3 is 1. The sum from index 1 to 1 is 1.

Editor Image

?