CODEM2 - Problem2


Two boxes contain the same total numbers of balls having some blacks and some whites in each.From each box "n" number of balls are drawn with replacement.Find the number of white balls in box A if composition of box B is given and such that probability that all white balls are drawn from box A is equal to the probability that the drawing from box B is either all whites or all blacks for the given number of drawings.

Input

T:no of testcases
Next T lines contain 3 integers n,x,y.

 

Output

For each testcase print in new line "impossible" if it is not possible to find no of white balls in box A else print no of white balls.

 

Example

Input:
1
2 3 4 Output: 5

Constraints:
 1<=n<=1000
 1<=x,y<=1000
 x=no of white balls in box B , y=no of black balls in box B

 

hide comments
mahilewets: 2017-09-08 21:41:45

P(A, W) is probability that all n balls drawn from box A are white
P(B, W) is probability that all n balls drawn from box B are white P(B, B) is probability that all n balls drawn from box B are black

Statement says P(A, W) =P(B, W) + P(B, B)

zubenkoivan: 2017-08-09 18:38:46

please add more test cases

racsosabe16: 2017-06-22 20:00:04

I couldn't understand correctly the problem >:V


Added by:Bhavik
Date:2014-02-04
Time limit:0.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:own problem(for CODE MARATHON)