Problem: Monocarp is a student at Berland State University. Due to recent changes in the Berland education system, Monocarp has to study only one subject — programming.
The academic term consists of days, and in order not to get expelled, Monocarp has to earn at least points during those days. There are two ways to earn points — completing practical tasks and attending lessons. For each practical task Monocarp fulfills, he earns points, and for each lesson he attends, he earns points.
Practical tasks are unlocked "each week" as the term goes on: the first task is unlocked on day (and can be completed on any day from to ), the second task is unlocked on day (and can be completed on any day from to ), the third task is unlocked on day , and so on.
Every day from to , there is a lesson which can be attended by Monocarp. And every day, Monocarp chooses whether to study or to rest the whole day. When Monocarp decides to study, he attends a lesson and can complete no more than tasks, which are already unlocked and not completed yet. If Monocarp rests the whole day, he skips a lesson and ignores tasks.
Monocarp wants to have as many days off as possible, i. e. he wants to maximize the number of days he rests. Help him calculate the maximum number of days he can rest!
Input Format: The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The only line of each test case contains four integers , , and (; ) — the number of days, the minimum total points Monocarp has to earn, the points for attending one lesson and points for completing one task.
It's guaranteed for each test case that it's possible not to be expelled if Monocarp will attend all lessons and will complete all tasks.
Output Format: For each test, print one integer — the maximum number of days Monocarp can rest without being expelled from University.
Note: In the first test case, the term lasts for day, so Monocarp should attend at day . Since attending one lesson already gives points (), so it doesn't matter, will Monocarp complete the task or not.
In the second test case, Monocarp can, for example, study at days and : at day he will attend a lesson for points and complete two tasks for another points. And at day he only attends a lesson for another points.
In the third test case, Monocarp can, for example, study at day : attending a lesson gives him point and solving out of available tasks gives him another points.
In the fourth test case, Monocarp has to attend all lessons and complete all tasks to get points.
In the fifth test case, Monocarp can, for example, study at days: — one lesson and first and second tasks; — one lesson and the third task; — one lesson and the fourth task; — one lesson and the fifth task; — one lesson and the sixth task.