VUDAAB - Progression

There are two very famous progressions, arithmetic progressions and geometric progressions. These progressions are a set of numbers that have a steady increase along the progression. Arithmetic progressions have a constant difference between all the numbers. Eg: 3, 5, 7, 9, 11, 13 is an arithmetic progression with difference 2. Geometric progressions have in common ratio. Eg: 2, 6, 18, 54 is a geometric progression with a ratio of 3.

Given 3 numbers your task is to find the fourth number of the progression, which can be either geometric or arithmetic.

Input

The first line will have a number 't' (1 <= t <= 100) the number of test cases, below are t lines each with three integers 'a', 'b', 'c' (-10000 <= a, b, c <= 10000, a != b, b != c) that are part of the progression of each case.

Output

Print a number 'd' for each test case that is the number following the progression, it is guaranteed that the output will be an integer.

Example

Input:
3
2 4 6
-6 4 14
-4 4 -4

Output:
8
24
4

ID RESULT TIME
code...



Added by:Edwin Guzman
Date:2011-08-11
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C C++ 4.3.2 JAVA RUBY
Resource:vudduus problem

hide comments
2012-10-15 16:10:29 :)
my whts next solution is taking 0.02sec but in this que it is giving tle?
2012-05-11 02:09:09 RANA
why u no move it to tutorials......
2012-05-11 02:09:09 Francky
Tutorial, please
2012-05-11 02:09:09 neerajcrespo
yeah.. me too just copied what's next solution. Tutorial.
2012-05-11 02:09:09 david_8k
Tutorial :D
2012-05-11 02:09:09 CryptoViral
move it to tutorial section Quite simple one
2012-05-11 02:09:09 LaFolle
Tutorial
2012-05-11 02:09:09 little master
What's next... :-)
2012-05-11 02:09:09 BOND
i just copied the solution from What's next (ACPC10A)...
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.