Solve the programming task below in a Python markdown code block.
Chef is playing a videogame, and is getting close to the end. He decides to finish the rest of the game in a single session.

There are X levels remaining in the game, and each level takes Chef Y minutes to complete. To protect against eye strain, Chef also decides that every time he completes 3 levels, he will take a Z minute break from playing. Note that there is no need to take this break if the game has been completed.

How much time (in minutes) will it take Chef to complete the game?

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- The first and only line of input will contain three space-separated integers X, Y, and Z.

------ Output Format ------ 

For each test case, output on a new line the answer — the length of Chef's gaming session.

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ X ≤ 100$
$5 ≤ Y ≤ 100$
$5 ≤ Z ≤ 15$

----- Sample Input 1 ------ 
4
2 12 10
3 12 10
7 20 8
24 45 15

----- Sample Output 1 ------ 
24
36
156
1185