{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\r\n\t\u003cimg align\u003d\"left\" alt\u003d\"http://www.clker.com/cliparts/2/9/c/7/11949867871570711906table_tennis_omar_abo-na_01.svg.hi.png\" height\u003d\"217\" hspace\u003d\"12\" src\u003d\"http://uva.onlinejudge.org/external/117/p11755.gif\" width\u003d\"237\" /\u003eTable tennis is a two/four player sport that originated in England. The scoring system of this game has changed with time. For this problem we will consider the two-player version of the game that abides by the following scoring rules (note that this rule is significantly different from the usual ones) \u0026ndash;\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026middot;Player 1 makes the first move. The players alternate serve every 5 points. That means serves [1,5] are done by player 1, serves [6, 10] are done by player 2, serves [11, 15] are done by player 1 and so on.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026middot;In each serve, one of the two players wins a point. The first player to reach 21 points wins the game.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026middot;If the scores are 20-20 (deuce), the scores are reset to 15-15.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tGiven a partial game, the probability of player 1 winning a point on his serve and the probability of player 1 winning a point on the opponent\u0026rsquo;s serve, can you find out the probability of player 1 winning the game?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tThe first line of input is an integer T(T\u0026lt;1000) that indicates the number of test cases. Each case consists of two lines. The first line is a string consisting of the letters \u0026ldquo;W\u0026rdquo; and \u0026ldquo;L\u0026rdquo; only. The length of this string is non-negative and can have a maximum value of 100. The string gives the status of the game so far. If the \u003cstrong\u003ei\u003csup\u003eth\u003c/sup\u003e\u003c/strong\u003e character (1 based) is \u0026ldquo;W\u0026rdquo;, that means player 1 won the \u003cstrong\u003ei\u003csup\u003eth\u003c/sup\u003e\u003c/strong\u003e point. Similarly, \u0026ldquo;L\u0026rdquo; indicates that the player 1 lost that point. The next line consists of two real numbers, \u003cstrong\u003eP1 P2\u003c/strong\u003e, in the range [0, 1], with at most 3 digits after the decimal point. P1 is the probability of player 1 winning a point on his serve and P2 is the probability of player 1 winning a point on player 2\u0026rsquo;s serve.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tFor each case, output the case number first. Then output the probability of player 1 winning the game rounded to 6 decimal places. If the given partial game is impossible according to any of the rules or data, output \u0026quot;-1.000000\u0026quot; instead. Outputs will be checked with special judge, so small precision errors will be ignored. Look at the samples for exact format.\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cp\u003e\r\n\t\u003cspan style\u003d\"font-family:courier new,courier,monospace;\"\u003e4\u003cbr /\u003e\r\n\tWWWWWWWWWWWWWWWWWWWW\u003cbr /\u003e\r\n\t1.0 0.234\u003cbr /\u003e\r\n\tWWWWWWWWWWWWWWWWWWWWW\u003cbr /\u003e\r\n\t0.3 0.99\u003cbr /\u003e\r\n\tWWWWWWWWWWWWWWWWWWWWWW\u003cbr /\u003e\r\n\t1.0 1.0\u003cbr /\u003e\r\n\tWL\u003cbr /\u003e\r\n\t0.7 0.3\u003c/span\u003e\u003c/p\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cp\u003e\r\n\t\u003cspan style\u003d\"font-family:courier new,courier,monospace;\"\u003eCase 1: 1.000000\u003cbr /\u003e\r\n\tCase 2: 1.000000\u003cbr /\u003e\r\n\tCase 3: -1.000000\u003cbr /\u003e\r\n\tCase 4: 0.444026\u003c/span\u003e\u003c/p\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tCase 1: Player 1 has already won 20 points and next it\u0026rsquo;s his serve. To win the next point (which is also the game point) he has a 1.0 probability of winning\u003c/p\u003e\r\n\u003cp\u003e\r\n\tCase 2: Player 1 has already won 21 points and he won the game and so it\u0026rsquo;s 1.000000.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tCase 3: The game should stop after 21 points, but the string has an extra \u0026ldquo;W\u0026rdquo; and makes this game invalid, so output is -1.000000.\u003c/p\u003e"}}]}