VUDAAB - Progression

no tags 

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

hide comments
:): 2012-10-15 16:10:29

my whts next solution is taking 0.02sec but in this que it is giving tle?

RANA: 2012-05-11 02:09:09

why u no move it to tutorials......

Francky: 2012-05-11 02:09:09

Tutorial, please

neerajcrespo: 2012-05-11 02:09:09

yeah.. me too just copied what's next solution. Tutorial.

david_8k: 2012-05-11 02:09:09

Tutorial :D

CryptoViral: 2012-05-11 02:09:09

move it to tutorial section Quite simple one

LaFolle: 2012-05-11 02:09:09

Tutorial

little master: 2012-05-11 02:09:09

What's next... :-)

BOND: 2012-05-11 02:09:09

i just copied the solution from What's next (ACPC10A)...


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