409427: GYM103540 A I will win
Description
Your participating a tournament. The tournament consists of $$$n$$$ games. Your probability to win a game is $$$\frac{p}{q}$$$. Initially your rank in the tournament is $$$n+1$$$. If you win a game your rank will decrease by 1. If you lose a game, you rank will increase by 1. What is the probability that you will win the tournament (i.e. your rank will be 1)? Print answer modulo $$$10^9 + 7$$$.
InputThe first line contains one integer $$$T (1 \leq T \leq 2 \cdot 10^5)$$$ — number of testcases.
Each of the next $$$T$$$ lines contain three integers — $$$n, p, q$$$ $$$(1 \leq n, p, q \leq 10^{18})$$$, $$$(p \leq q)$$$.
OutputFor each test case print your probability of winning the tournament. If it is $$$\frac{x}{y}$$$ print $$$x \cdot y^{-1}$$$ modulo $$$10^9 + 7$$$.
ExampleInput4 10000 1 1 1000000000000000000 2 2 2 1 2 1000000000000000000 900000000000000000 1000000000000000000Output
1 1 250000002 100777456Note
In the first test case, you will win every game, so answer is 1.
In the second test case, probability is $$$\frac{1}{4}$$$. So the answer will $$$1 \cdot 4^{-1}$$$ modulo $$$10^9 + 7$$$. Modular inverse of $$$4$$$ (mod $$$10000007$$$) is $$$2500002$$$. So the answer is $$$2500002$$$.