Limits 4s, 512 MB

You are given two integers ll and rr. You need to find the value of

x=lrx(x+1)\prod_{x=l}^{r}x^{(x+1)}

As the value of this equation may be large, you need to find its remainder modulo (109+710^9+7).

Input

The first line will contain an integer tt (1t51 ≤ t ≤ 5), the number of test cases.

Each of the next tt lines will contain two integers ll and rr (1lr1091 ≤ l ≤ r ≤ 10^9).

Output

Find the value of the aforementioned product modulo (109+710^9+7).

Sample

InputOutput
2
1 2
100 100
8
409005006

Submit

Login to submit.

Statistics

56% Solution Ratio
SwampFireEarliest, Dec '19
steinumFastest, 0.0s
SwampFireLightest, 131 kB
steinumShortest, 910B
Toph uses cookies. By continuing you agree to our Cookie Policy.