Button Bashing
You recently acquired a new microwave, and noticed that it provides a large number of buttons to be able to quickly specify the time that the microwave should be running for. There are buttons both for adding time, and for subtracting time. You wonder how efficient you can be when entering cooking times: you want to minimize the number of required button presses.
The microwave can be running for at least seconds, and at most hour. If a button press would result in a cooking time of less than seconds, the microwave will set the cooking time to seconds. If a button press would result in a cooking time of more than hour, the microwave will set the cooking time to hour. Initially, the microwave will run for seconds. There will always be a button adding at least second to the cooking time.
Given the buttons that the microwave provides for entering cooking times, determine the least amount of button presses required to let the microwave run for a certain amount of time. If it is not possible to enter the desired cooking time precisely, determine the smallest achievable cooking time above the target, and the minimum number of button presses required for that cooking time, instead. The microwave does not allow to adjust the cooking time once it has started cooking.
Input
The first line contains the number of test cases . After that per test case:
one line with two integers and : the number of buttons available to change the cooking time, and the desired cooking time in seconds, respectively.
one line with integers : the number of seconds added to the cooking time when button is pressed.
Output
Per test case:
one line with two integers: the minimum number of button presses required to reach the required cooking time, and the minimum number of extra seconds that the microwave must be running for, respectively.