405558: GYM101992 F MO Salah running down the wing

Memory Limit:1024 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. MO Salah running down the wingtime limit per test3 secondsmemory limit per test1024 megabytesinputmosalah.inoutputstandard output

The ECPC judges were discussing Salah's performance this season. Some of them think that it is lower than his level in the last season, but others think that it is too early to judge him. They all agreed that if he ended this season with the same average number of goals as the last season, then there is no need to worry.

Given four integers, $$$N$$$, $$$M$$$, $$$X$$$ and $$$Y$$$ representing his average number of goals per match in the last season, the number of goals he scored so far in the current season, the number of matches that were already played and the number of remaining matches respectively.

What is the minimum number of goals he needs to score in the remaining matches to have at least the same average number of goals as the last season ?

Input

The first line of the input is the number of test cases $$$T$$$. Each test case consists of four integers $$$N$$$, $$$M$$$, $$$X$$$, and $$$Y$$$, where $$$0 \leq N, M, X, Y \leq 100$$$ and $$$X + Y > 0$$$.

Output

For each test case output a single line containing the minimum number of goals or $$$-1$$$ if Salah can't make it.

ExampleInput
4
1 1 37 1
5 1 1 37
1 0 1 0
2 6 1 2
Output
37
189
-1
0

加入题单

上一题 下一题 算法标签: