SOLVE

LATER

An Excursion In Mathematics

/

As Brutus betrayed Caesar he is planning to attack Brutus. But he knows Brutus cannot be defeated easily so he plans to use the excalibur sword. But there is one problem. To activate the sword he needs to solve the problem written on the sword. Can you help Caesar activate the sword by solving this problem??

Given the values of *A*(\(X^2+Y^2+Z^2\)), *B*(\(X^4+Y^4+Z^4\)), *C*(\(X^5+Y^5+Z^5\)). Calculate the value of sum of values of \(X^i+Y^i+Z^i\) where *i* goes from *L* to *R* modulo 1e9+7.

\(Input :\)

First line of the Input contains an integer *T* denoting the number of testcases. Each testcase contains two lines.
The first line contains *3* integers *A*, *B* and *C*.
The next line contains *2* integers *L* and *R*

\(Output :\)

print a single integer denoting the summation.

\(Constraints\) :

\(1 \le X,Y,Z \le 3000\)

\(1 \le T \le 10^3\)

\(1 \le L \le R \le 10^{18}\)

Problem setter : Sheldon Tauro

Time Limit:
1.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Initializing Code Editor...