#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
long long fib(long long);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long long *, ...);
int main() {
  long long int n, t, sum = 0, i, m, x, y, temp;
  scanf("%lld", &t);
  while (t--) {
    sum = 0;
    scanf("%lld%lld", &n, &m);
    x = fib(m + 2);
    y = fib(n + 1);
    sum = (x - y) % 1000000007;
    if (sum < 0) {
      sum = sum + 1000000007;
      printf("%lld\n", (sum));
    } else
      printf("%lld\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xeb6(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     120b <main+0xdb>
movq   $0x0,-0x20(%rbp)
lea    0xe7f(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x30(%rbp),%rdi
add    $0x2,%rdi
call   1050 <fib@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1050 <fib@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x40(%rbp),%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    11f6 <main+0xc6>
mov    -0x20(%rbp),%rax
add    $0x3b9aca07,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <main+0xd6>
mov    -0x20(%rbp),%rsi
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
jmp    1159 <main+0x29>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebf(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subq   $0x1,(%rsp)
jb     11f7 <main+0xc7>
lea    0xe9f(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
movabs $0x89705f3112a28fe5,%rbp
5f 70 89
lea    0xe8d(%rip),%r13
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%rdi
add    $0x2,%rdi
call   1050 <fib@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rdi
add    $0x1,%rdi
call   1050 <fib@plt>
sub    %rax,%rbx
mov    %rbx,%rax
imul   %rbp
add    %rbx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca07,%rdx,%rax
mov    %rbx,%rcx
sub    %rax,%rcx
neg    %rax
test   %rcx,%rcx
lea    0x3b9aca07(%rbx,%rax,1),%rsi
3b
cmovns %rcx,%rsi
mov    %r13,%rdi
call   1030 <printf@plt>
subq   $0x1,(%rsp)
jae    1180 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [9 x i8] c"%lld%lld\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %4
%10 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
br label %11
11: ; preds = %37, %0
%12 = load i64, i64* %3
%13 = add nsw i64 %12, -1
store i64 %13, i64* %3
%14 = icmp ne i64 %12, 0
br i1 %14, label %15, label %38
15: ; preds = %11
store i64 0, i64* %4
%16 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %6)
%17 = load i64, i64* %6
%18 = add nsw i64 %17, 2
%19 = call i64 @fib(i64 %18)
store i64 %19, i64* %7
%20 = load i64, i64* %2
%21 = add nsw i64 %20, 1
%22 = call i64 @fib(i64 %21)
store i64 %22, i64* %8
%23 = load i64, i64* %7
%24 = load i64, i64* %8
%25 = sub nsw i64 %23, %24
%26 = srem i64 %25, 1000000007
store i64 %26, i64* %4
%27 = load i64, i64* %4
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %15
%30 = load i64, i64* %4
%31 = add nsw i64 %30, 1000000007
store i64 %31, i64* %4
%32 = load i64, i64* %4
%33 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %32)
br label %37
34: ; preds = %15
%35 = load i64, i64* %4
%36 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %35)
br label %37
37: ; preds = %34, %29
br label %11
38: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [9 x i8] c"%lld%lld\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%8 = load i64, i64* %2
%9 = add nsw i64 %8, -1
store i64 %9, i64* %2
%10 = icmp eq i64 %8, 0
br i1 %10, label %28, label %11
11: ; preds = %0, %11
%12 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64* %1, i64* %3)
%13 = load i64, i64* %3
%14 = add nsw i64 %13, 2
%15 = call i64 @fib(i64 %14)
%16 = load i64, i64* %1
%17 = add nsw i64 %16, 1
%18 = call i64 @fib(i64 %17)
%19 = sub nsw i64 %15, %18
%20 = srem i64 %19, 1000000007
%21 = icmp slt i64 %20, 0
%22 = add nsw i64 %20, 1000000007
%23 = select i1 %21, i64 %22, i64 %20
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %23)
%25 = load i64, i64* %2
%26 = add nsw i64 %25, -1
store i64 %26, i64* %2
%27 = icmp eq i64 %25, 0
br i1 %27, label %28, label %11
28: ; preds = %11, %0
ret i32 0
}