PRB7: What's Next? // Beginner

 
A relatively simple task for humans to do is to identify the next number in an arithmetic or geometric sequence of numbers. For example, given the sequence of numbers 4, 8, and 12, we know that the next number in the sequence is 16 since each number is followed by a number increasing it by 4.

Alternatively, given the sequence of numbers 2, 4, and 8, we know that the next number in the sequence is 16 since each number twice its predecessor.

Your task is to write a program that will deduce the next integer in a given sequence of three integers where the same arithmetic or geometric operation is applied to each integer to produce the next. The only operations that will be used are addition, subtraction, multiplication, or division.

Input Format

An integer N representing the number of following lines containing data. Each input line contains three space-seperated integers. The integers represent an arithmetic or geometric sequence as described above.

Sample Input

3
7 21 35
-10 20 -40
64 16 4

Output Format

Your program should print out N lines. Each line contain the next integer in the matching input line given.

Sample Output

49
80
1




You must be logged in to submit a solution.