PRJAN15A - An Arithmetic Problem

A sequence is an arithmetic sequence if every two successive numbers have the same difference. Suppose this is a sequence of numbers:

a1, a2, a3, ... an

This is an arithmetic sequence if ai - ai+1 is the same for each i from 1 to n-1.

You are given first 3 terms of a sequence and the value of n. If it is an arithmetic sequence you must print the nth term. Otherwise you must print “Error”.

Input

In first line there will an integer T denoting the number of test cases. Each of the next 3 lines will contain 4 integers a1, a2, a3 and n.

Output Format

In each line specify the case number and print the answer.

Constraints

-300 <= a1, a2, a3 <= 300

1 <= n <= 1000

Example

Input:
3
1 2 3 10
1 4 3 10
15 30 45 5

Output:
Case 1: 10
Case 2: Error
Case 3: 75

Problem-setter: Shafaet Ashraf


Added by:Shafaet
Date:2015-01-29
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 JS-MONKEY
Resource:Progrkriya Contest January 2015

hide comments
2015-01-31 05:04:48 Mitch Schwartz
Moved to tutorial, it is very simple.

The correct spelling is "arithmetic".
2015-01-31 05:04:48 Sachin Verma
:P


Last edit: 2015-01-29 17:48:28
2015-01-31 05:04:48 Namit Agrawal
it must be a tutorial question..!!
2015-01-31 05:04:48 vishrut mishra
it should be tutorial
2015-01-31 05:04:48 Vamsi Krishna Avula
tutorial problem(?)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.