NAJGC - Game of chocolate

Ben and Gwen gets two bag of chocolate from grandpa. Ben’s bag contain X1 kit-Kat and Y1 Park chocolate. Gwen’s bag contain X2 kit-Kat and Y2 Park. But Ben don’t like chocolate, so he decided to give all the chocolate to Gwen. But he want to play a game with Gwen. The game is very simple, and if Gwen win the game he will give all the chocolate to Gwen. The game follow those rules:

  1. First Ben take a chocolate from his bag and it will be unknown to Gwen.
  2. Then he placed the chocolate to Gwen bag.
  3. Then Gwen take a chocolate form her bag.
  4. If Gwen take chocolate is same as Ben chocolate then she win the game and get all the chocolate from Ben.

Now, Find out the probability of Gwen win in the game.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each line contain four integer x1, y1, x2, y2 which denotes ben chocolate and Gwen chocolate respectively. Where 0 ≤ x1, y1, x2, y2 ≤ 1000000

Output

For each test case print the case number and Gwen win probability in a/b format, where a/b is irreducible fraction. If in any test case probability is zero, just print ‘0’ (Case x: 0).

Sample

Input
2
3 5 4 5
1 3 4 8
Output
Case 1: 9/16
Case 2: 8/13
 

Authored By: Tanvir Hasan Anick


Added by:Najmuzzaman
Date:2014-10-31
Time limit:0.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2015-04-03 23:00:32 Dhruv k14
AC with long long int in C,2 WA due to printing error, hehehe easy one to score 0.2 points from :P
2015-03-28 11:31:29 Shubham Bansal
got 4 WA's because of format only.. phew..!
2015-03-27 05:30:42 MathiasSM
x1,x2,y1,y2>10^9 in my experience. Leppy's comment wasn't really helpful (no offense).
2015-03-08 21:52:34 Archangel
Handle 0 case properly... costed me a WA
2015-03-06 17:56:00 SM_92
2 WA only because of using int
AC after using long long

Last edit: 2015-03-06 17:56:48
2015-02-24 18:47:01 Daksh
Easy Math :)
2015-02-06 12:06:03 Rishabh
constraints will require an unsigned 4 bit integer data type
2015-01-24 15:22:55 maradona
The question that arises, why are the constraints hidden??
2015-01-05 23:38:32 Sahil Dua
177th one to get AC :D
2014-12-12 17:17:40 LeppyR64
0 <= x1,y1,x2,y2 < 10^5

Last edit: 2014-12-12 18:30:45
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.