Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Kitorp and His Wife

By RasheedAbid, DarkknightRHZ · Limits 1s, 512 MB

To encourage Kitorp’s promising coding career, his wife Asiar, offers him a prize if he wins (at least) two contest in a row in a three-set contest with his wife and Tourits alternatively: Asiar-Tourits-Asiar or Tourits-Asiar-Tourits, according to Kitorp’s choice.

Now, the probability of Kitorp defeating the opponents are given. Find out the probability of Kitorp winning the prize if he optimally chooses the series. Also, you need to find the expected number of wins for the chosen condition.

Input

First line will contain the number of test cases T (0 < T ≤ 100000). The following T lines will have two double numbers t and a, the probability of defeating Tourits and Asiar.

Output

Output the probability of Kitorp winning the prize and the expected number of wins. Error less than 10-6 will be ignored.

Sample

InputOutput
1
0.5 0.5
0.375 1.5

    Discussion

    Statistics


    31% Solution Ratio

    curly_bracesEarliest, May '18

    farhan777Fastest, 106102.5s

    curly_bracesLightest, 2.4 MB

    curly_bracesShortest, 221B

    Submit

    Login to submit