# Legends of the Three Kingdoms

Time Limit: 8000/4000 MS (Java/Others)

Memory Limit: 262144/262144 K (Java/Others)

## Description

In the game of Three Kingdoms’ Legends, there are 4 players called the Monarch, the Minister, the Rebel and theTraitor. They have $h_1, h_2, h_3, and h_4$ health points at the beginning. The players with positive health points aresurviving; the players with zero health points are dead.
The players take turns to move in each round of the game: the Monarch moves first, then the Rebel, the Minister,and finally the Traitor. In a player’s turn, if he/she is surviving, he/she must attack a player and the health points of that player will decrease by 1. Note that the dead players cannot attack the other players, and self attacking isnot allowed.
When one of the following events happens, the game ends immediately.
$\bullet$ Both of the Rebel and the Traitor are dead: The Monarch and the Minister win the game, no matter theminister is surviving or not.
$\bullet$ The Monarch is dead: If the Traitor is surviving and all the other players are dead, the Traitor wins; otherwisethe Rebel wins, no matter he/she is surviving or not.
The players have the following common knowledge on their strategies.
$\bullet$ The Monarch and the Minister never attack with each other.
$\bullet$ After attacking the chosen player, the probability of winning the game is maximized.
$\bullet$ If there are multiple players to choose, such that the winning probability is the same and maximized, all theseplayers will be chosen by equal chance.

## Input

The first line is the number of test cases up to 10000. For each test case, there is a line containing 4 integers $h_1, h_2, h_3 and h_4$ (0 < $h_1$ < 40, 0 ≤ $h_2$ < 40, 0 ≤ $h_3$ < 40, 0 ≤ $h_4$ < 40).

## Output

For each test case, output a line of 3 winning probabilities with the precision of 6 digits, in which the first one is the Monarch and the Minister’s winning probability, the second one is the Rebel’s and the last one is the Traitor’s.

## Sample Input

4
1 1 1 1
1 0 1 1
1 1 1 2
2 1 2 6

## Sample Output

1.000000 0.000000 0.000000
0.000000 0.500000 0.500000
0.500000 0.500000 0.000000
0.250000 0.500000 0.250000

jiangzijing2015

## Source

2017ACM/ICPC亚洲区沈阳站-重现赛（感谢东北大学）