Alice and Bob are playing a game. Initially, Alice has $$$x$$$ chips, and Bob has $$$y$$$ chips.
The game proceeds in several rounds. In each round, Alice wins with a probability of $$$p_0$$$, Bob wins with a probability of $$$p_1$$$, and there is a probability of $$$1 - p_0 - p_1$$$ for a draw.
If there is a draw, the game immediately moves to the next round. Otherwise, if the number of the winner's chips is not smaller than the number of the loser's chips, the winner wins the entire game, and the game ends; otherwise, the loser loses an amount of chips equal to the winner's current chips, and the game moves to the next round.
Note that after each round of the game, no one's chips will increase.
You are asked to find the probability that Alice will ultimately win the entire game.
The first line contains an integer $$$T$$$ $$$(1 \leq T \leq 10^5)$$$, representing the number of test cases.
For each test case, the first line contains two integers $$$x$$$ and $$$y$$$ $$$(1 \leq x, y \leq 10^9)$$$, representing the initial number of chips Alice and Bob have, respectively.
The second line contains three non-negative integers $$$a_0$$$, $$$a_1$$$, and $$$b$$$ $$$(1 \leq a_0 + a_1 \leq b \lt 998244353)$$$, representing $$$p_0 = \frac{a_0}{b}$$$, $$$p_1 = \frac{a_1}{b}$$$.
For each test case, output one line containing an integer representing the probability that Alice will win the entire game, modulo $$$998244353$$$.
31 12 2 61 32 3 63 47 3 15
499122177 910398850 220911476
For the first test case, since both players have the same number of chips and the same probability of winning a round, the probability of either Alice or Bob winning the entire game is $$$\frac{1}{2}$$$.
For the second test case, Alice must win three rounds before Bob wins a single round to win the entire game. If a round does not end in a draw, Alice wins with a probability of $$$\frac{2}{5}$$$, so Alice's final winning probability is $$$\left(\frac{2}{5}\right)^3 = \frac{8}{125}$$$.
| Название |
|---|


