Game, Set and Match#3068

Game, Set and Match

1 second
64 megabytes
Medium

In this problem, you need to help compute the probability of winning at tennis. Here is a brief explanation of how the scoring system works. In a tennis match, players play a certain number of consecutive sets. Each set consists of a series of games (and may include a tie-break if needed). Finally, each game is made up of points.

Points. Each point starts with one of the players serving (i.e., hitting the ball into the service box in the opposite court) and the other player receiving the serve. The server then attempts to return the ball into the server's court, and the players alternate hitting the ball across the net. When one of the players fails to make a legal return (for example, if the ball is knocked out of the court), he or she loses the point. The specifics of how points are won are not important to us.

Games. The scoring system within a game is quite peculiar. As the player wins points in a game, the score goes from the initial value of (read as "love") to , , or . There is no pre-determined limit to the length of a game (that is, the number of points played), but a player's score is always indicated by one of these numbers, according to the following rules. When a player has three points (score ) and wins the next point, he wins the game unless the score was - (read as "deuce") to start. A player needs to win two consecutive points from deuce to win the game. Winning one gives him advantage; if followed by a second winning point, the game is won by him, but if followed by a losing point, the score returns to deuce.

Example: at -, if the first player wins the next point, he wins the game. However, if the second player wins the next three points, the game is his.

Sets. A player wins a set if he wins at least four games (in the current set) and is two games ahead of his opponent. If the score in games reaches -, a tie-break is played instead to decide the set. Example: at 5-4, if the first player wins the next game, he takes the set -. If he loses, the set is still undecided and may eventually end -, -, or in a tie-break.

Tie-break. A tie-break (and the set containing it) is won when a player wins at least seven points, with a margin of two points or more.

Match. The winner of the match is the first player to win sets (the wins do not need to be consecutive). Thus, a match may consist of or sets depending on how the games proceed.

Rafa has carefully studied his past performances against his next opponent and knows he wins each point with probability exactly , regardless of whether he is serving or receiving, and regardless of all other points played. Can you help him estimate his chances of winning the match?

Input

Each test case is described by a single floating-point number , 0 \leq p \leq 1, on its own line. A value of for marks the end of the input.

Output

For each test case, print a single line with the probabilities that Rafa wins a given game, set, and match, respectively. These three numbers must be separated by a space character. Your answers should be accurate to within an absolute error of 10^{-6}.

Examples

Example 1

Loading
Loading