Given a number n, print the value of F(n) given that
F(1) = A + B and
F(2) = B + C.
Here A, B and C are integer inputs provided to the program.For n > 2, F(n) = F(n-1) - F(n-2). Since F(n) can be large, print the answer modulo (109+7).
The first line contains integer T, denoting number of test cases.Then T test cases follow. The first line of each test case contains integer N A B C, denoting the number and values of constant A,B,C respectively.
Print the answer of each test case in a new line.
1 <= T <= 100
1 <= A,B,C <= 109
1 <= n <= 1012
2 2 3 4
3 2 3 4
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.