Consider a sequence fn(n≥0). You do not know the values of fn. However, function F(x) defined as follows:
F(x)=∑n≥0fnxn=1+dx+ex21+ax+bx2+cx3
You are given a,b,c,d,e,N. Your task is to calculate fN.
Since this value can be very large, print it modulo 1000000007(109+7). You can read about modular arithmetic here.
You are given T test cases.
Input format
Output format
For each test case (in a separate line), print the value fN modulo (109+7).
Constraints
1≤T≤104−109≤a,b,c,d,e≤1090≤N≤1018
We have T=2.
In the first test case, F(x)=11−x=1+x+x2+.., we can see that f5 would correspond to coefficient of x5 which is 1.
In the second test case, F(x)=11+x=1−x+x2−x3+.., we can see that f1 would correspond to coefficient of x which is −1. However, the modulo value is 1000000006.