Sounak’s girlfriend Shreyashi is very fond of numbers and mathematics. She expects her boyfriend to know at least basic mathematics and decides to put Sounak to test by giving him the task of finding the final result of a game that she has developed called the Addition Game.
The game proceeds as follows:
There are two Players, Player 1 and Player 2 involved in the game. Player 1 starts with an integer A and similarly Player 2 starts with an integer B.
A constant integer X is also selected at the beginning of the game.
Now, the game consists of N turns which are described as follows:
In Turn 1, Player 1 adds 1 * X to the current value of A.
In Turn 2, Player 2 adds 2 * X to the current value of B.
In Turn 3, Player 1 adds 3 * X to the current value of A.
In Turn 4, Player 2 adds 4 * X to the current value of B.
In Turn 5, Player 1 adds 5 * X to the current value of A.
The game continues in this fashion till the Nth Turn.
The final result of the game is given by the absolute value of the difference between the final values of A and B.
Now although Sounak loves Shreyashi very much, unlike his girlfriend he is not very fond of numbers. So he asks you for help. Please help Sounak by finding the final result of the Addition Game efficiently since he does not have much time before his next date with Shreyashi.
The first line of input contains T, the number of test cases.
The T test cases follow.
The only input line for each test case contains four space separated integers denoting A, B, X and N.
For each test case output the final result of the Addition Game in a new line.
1≤T≤20
0≤A≤109
0≤B≤109
0≤X≤9
0≤N≤109
Test Case 1:
Here A=1, B=2, X=1 and N=3.
In Turn 1, A = 1 + 1*1 = 2
In Turn 2, B = 2 + 1*2 = 4
In Turn 3, A = 2 + 1*3 = 5
Therefore, final result = |A - B| = |5 - 4| = 1.
Test Case 2:
Here A=2, B=3, X=2 and N=2.
In Turn 1, A = 2 + 2*1 = 4
In Turn 2, B = 3 + 2*2 = 7
Therefore, final result = |A - B| = |4 - 7| = 3.