#P1860B. Fancy Coins
Fancy Coins
Description
Monocarp is going to make a purchase with cost of exactly burles.
He has two types of coins, in the following quantities:
- coins worth burle: regular coins and infinitely many fancy coins;
- coins worth burles: regular coins and infinitely many fancy coins.
Monocarp wants to make his purchase in such a way that there's no change — the total worth of provided coins is exactly . He can use both regular and fancy coins. However, he wants to spend as little fancy coins as possible.
What's the smallest total number of fancy coins he can use to make a purchase?
The first line contains a single integer () — the number of testcases.
The only line of each testcase contains four integers and (; ; ) — the cost of the purchase, the worth of the second type of coin and the amounts of regular coins of both types, respectively.
For each testcase, print a single integer — the smallest total number of fancy coins Monocarp can use to make a purchase.
Input
The first line contains a single integer () — the number of testcases.
The only line of each testcase contains four integers and (; ; ) — the cost of the purchase, the worth of the second type of coin and the amounts of regular coins of both types, respectively.
Output
For each testcase, print a single integer — the smallest total number of fancy coins Monocarp can use to make a purchase.
Note
In the first testcase, there are no regular coins of either type. Monocarp can use fancy coins worth burle and fancy coins worth (since ) burles to get total burles with total fancy coins.
In the second testcase, Monocarp has a lot of regular coins of both types. He can use regular coins worth burle, for example. Notice that Monocarp doesn't have to minimize the total number of used coins. That way he uses fancy coins.
In the third testcase, Monocarp can use regular coins worth burle and regular coin worth burles. That will get him to total burles when he needs . So, fancy coin worth burles is enough.