#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 fibo(long long);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int t;
  long long int m, n, a, b, i, j;
  long long int sum;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld%lld", &m, &n);
    if (m == 0)
      i = 1;
    else
      i = fibo(m + 1);
    if (n == 0)
      j = 1;
    else
      j = fibo(n + 2);
    sum = (j - i) % 1000000007;
    if (sum < 0)
      sum += 1000000007;
    printf("%lld\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1211 <main+0xe1>
lea    0xe97(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1193 <main+0x63>
movq   $0x1,-0x30(%rbp)
jmp    11a4 <main+0x74>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1050 <fibo@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11bc <main+0x8c>
movq   $0x1,-0x38(%rbp)
jmp    11cd <main+0x9d>
mov    -0x18(%rbp),%rdi
add    $0x2,%rdi
call   1050 <fibo@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jge    11fc <main+0xcc>
mov    -0x40(%rbp),%rax
add    $0x3b9aca07,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1030 <printf@plt>
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x40,%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    0xebb(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    1169 <main+0x39>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
movabs $0x89705f3112a28fe5,%r14
5f 70 89
lea    0xe88(%rip),%r13
jmp    11d8 <main+0xa8>
cs nopw 0x0(%rax,%rax,1)
sub    %rbp,%rbx
mov    %rbx,%rax
imul   %r14
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>
subl   $0x1,0x4(%rsp)
jb     1158 <main+0x28>
lea    0xe24(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%rdi
mov    $0x1,%ebx
mov    $0x1,%ebp
test   %rdi,%rdi
je     120c <main+0xdc>
add    $0x1,%rdi
call   1050 <fibo@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1190 <main+0x60>
add    $0x2,%rdi
call   1050 <fibo@plt>
mov    %rax,%rbx
jmp    1190 <main+0x60>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\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 i32
%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
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %42, %0
%12 = load i32, i32* %2
%13 = add nsw i32 %12, -1
store i32 %13, i32* %2
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %45
15: ; preds = %11
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64* %3, i64* %4)
%17 = load i64, i64* %3
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i64 1, i64* %7
br label %24
20: ; preds = %15
%21 = load i64, i64* %3
%22 = add nsw i64 %21, 1
%23 = call i64 @fibo(i64 %22)
store i64 %23, i64* %7
br label %24
24: ; preds = %20, %19
%25 = load i64, i64* %4
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
store i64 1, i64* %8
br label %32
28: ; preds = %24
%29 = load i64, i64* %4
%30 = add nsw i64 %29, 2
%31 = call i64 @fibo(i64 %30)
store i64 %31, i64* %8
br label %32
32: ; preds = %28, %27
%33 = load i64, i64* %8
%34 = load i64, i64* %7
%35 = sub nsw i64 %33, %34
%36 = srem i64 %35, 1000000007
store i64 %36, i64* %9
%37 = load i64, i64* %9
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %32
%40 = load i64, i64* %9
%41 = add nsw i64 %40, 1000000007
store i64 %41, i64* %9
br label %42
42: ; preds = %39, %32
%43 = load i64, i64* %9
%44 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %43)
br label %11
45: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\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 = bitcast i32* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp eq i32 %8, 0
br i1 %10, label %36, label %11
11: ; preds = %0, %25
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3)
%13 = load i64, i64* %2
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = add nsw i64 %13, 1
%17 = call i64 @fibo(i64 %16)
br label %18
18: ; preds = %11, %15
%19 = phi i64 [ %17, %15 ], [ 1, %11 ]
%20 = load i64, i64* %3
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = add nsw i64 %20, 2
%24 = call i64 @fibo(i64 %23)
br label %25
25: ; preds = %18, %22
%26 = phi i64 [ %24, %22 ], [ 1, %18 ]
%27 = sub nsw i64 %26, %19
%28 = srem i64 %27, 1000000007
%29 = icmp slt i64 %28, 0
%30 = add nsw i64 %28, 1000000007
%31 = select i1 %29, i64 %30, i64 %28
%32 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %31)
%33 = load i32, i32* %1
%34 = add nsw i32 %33, -1
store i32 %34, i32* %1
%35 = icmp eq i32 %33, 0
br i1 %35, label %36, label %11
36: ; preds = %25, %0
ret i32 0
}