J. Rock Paper Scissors
time limit per test
6 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

During the holy month of Ramadan, Rami and Yassine have a special tradition. Every night, after breaking their fast at iftar, they head to their favorite coffee place to engage in friendly games while waiting for suhoor. One evening, they decide to play a modified version of Rock-Paper-Scissors as a card game.

There are only three types of cards: Rock, Paper, and Scissors.

  • Rami starts with $$$R_1$$$ Rock cards, $$$P_1$$$ Paper cards, and $$$S_1$$$ Scissors cards.
  • Yassine starts with $$$R_2$$$ Rock cards, $$$P_2$$$ Paper cards, and $$$S_2$$$ Scissors cards.
  • The total number of cards for Rami is $$$n_1 = R_1 + P_1 + S_1$$$, and for Yassine, it is $$$n_2 = R_2 + P_2 + S_2$$$.
  • Both players know the composition of each other's deck before the game starts.
  • Before playing, each player privately shuffles their deck, so that it is impossible for the opponent to gain any insight into the order of their cards.

The game proceeds in turns as follows:

  1. Card Selection:
    • Each player privately inspects his deck, and chooses a single card.
    • The selection is made simultaneously, and neither player knows the opponent's choice beforehand.
  2. Card Reveal & Outcome:
    • Both players reveal their chosen card at the same time.
    • The result follows standard Rock-Paper-Scissors rules:
      • Rock beats Scissors
      • Scissors beats Paper
      • Paper beats Rock
      • If both players select the same type, it is a draw.
  3. Card Handling:
    • If a player wins a round, their opponent's card is discarded permanently. The winning player keeps their card and returns it to their deck.
    • If the round is a draw, both players take back their respective cards.
  4. Winning Condition:
    • A player loses immediately if their deck no longer contains at least one of the three card types (Rock, Paper, or Scissors).
    • The game continues until one player loses.

Now both players play optimally, and fairly:

  • Both players play optimally, meaning they make decisions to maximize their probability of winning the game.
  • Both players play fairly, meaning they do not cheat, communicate, or exploit unintended mechanics.

Given the initial deck compositions $$$R_1, P_1, S_1$$$ for Rami and $$$R_2, P_2, S_2$$$ for Yassine, compute the probability of each player winning the game.

Input

A single line containing six integers $$$1 \leq R_1, P_1, S_1, R_2, P_2, S_2 \leq 18$$$.

It is guaranteed that: $$$$$$ 3 \leq \max(R_1 + P_1 + S_1, R_2 + P_2 + S_2) \leq 20 $$$$$$

Output

Print two floating-point numbers $$$0 \leq p_1, p_2 \leq 1$$$:

  • $$$p_1$$$: the probability that Rami wins the game
  • $$$p_2$$$: the probability that Yassine wins the game
Examples
Input
1 1 1 1 1 1
Output
0.5 0.5
Input
4 5 6 5 5 5
Output
0.482774 0.517226
Note

The first test case corresponds to a traditional rock paper scissor game. It can be proven that the optimal strategy for each player, is to choose any card, with the same probability.