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(X2+Y2+Z2), B(X4+Y4+Z4), C(X5+Y5+Z5). Calculate the value of sum of values of Xi+Yi+Zi 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≤X,Y,Z≤3000
1≤T≤103
1≤L≤R≤1018
Problem setter : Sheldon Tauro