You do not need to know the board game Risk to solve this problem. Every die in this problem is a six sided die.
Rizk is a Bulgarian variant of Risk. Two players fight, each commanding an army. On your turn you either attack or add units to your army, never both. An attack works like this.
Player A attacks with Ua units and player B defends with Ub units. The attacker has Da dice available and the defender has Dd dice available. One attack repeats the following steps.
The player who still has units at the end wins the battle. Exactly one player always has units left.
Mike and his brother have been playing for hours. Neither dares to attack, because both fear losing. It is Mike's turn, and he has decided to cheat a little in order to win. He attacks only if his chance of winning this turn is at least 75 percent. Mike has X units and his brother has Y units. How many units does Mike have to sneak into the game so that his chance of winning this turn is at least 75 percent?
The first line contains one integer T, the number of test cases. Each of the next T lines contains four integers Da, Dd, X, Y separated by spaces, with the meaning given above.
For each test case, print on its own line the smallest number of extra units Mike needs so that his chance of winning this turn is at least 75 percent. Print 0 if he already has at least a 75 percent chance.