Limits 1s, 512 MB

Jimmy and Jamy are two brothers. They like to play with colored marble.

Jimmy has NN boxes with three different colors (red, green, and blue) marble. Each box contains one or more red, green, and blue color marble.

Now Jimmy randomly selects a colored marble and asked his brother (Jamy) what is the probability that it comes from “I” box, where “I” means the index number of the given box.

Jamy is a lazy boy and he is unable to respond to his brother (Jimmy).

Please help Jamy to solve his problem. Every box has an equal probability of being selected.

Input

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

Each case start with an integer NN (1N1001 \le N \le 100), SS and II (1IN1 \le I \le N) where NN denoting the number of box and SS is a character string (“red” or “green” or “blue”) and II is the index number of selected box.

Next, N lines contain three integer RR (1R<1001 \le R < 100), GG (1G1001 \le G \le 100), and BB (1B1001 \le B \le 100) where RR, GG, BB denoting the number of color marbles.

Output

For each test case, print a line in the format, "Case T: P", where TT is the case number and PP is the probability of Jamy tasks and rounded to five places after the decimal point.

Sample

InputOutput
1
2 red 1
1 3 3
2 3 4
Case 1: 0.39130

Submit

Login to submit.

Contributors

Statistics

90% Solution Ratio
Rakib.862542Earliest, Sep '21
Alom_ShantoFastest, 0.0s
Alom_ShantoLightest, 5.5 kB
user.0133Shortest, 899B
Toph uses cookies. By continuing you agree to our Cookie Policy.