

The first line of the input contains a single integer 'T', denoting the number of test cases. Then the 'T' test case follows.
The first and the only line of each test case consists of 4 non-negative integers 'N', 'R', 'K' and 'C', as described in the problem statement.
For each test case, print a single integer in a new line, denoting the maximum number of usable pens you can get.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10^5
1 <= N <= 10^9
0 <= R <= 10^9
1 <= K <= 10^9
1 <= C <= 10^9
Time limit: 1 sec
First Digit One
Special Digit Numbers
Minimize Maximum Adjacent Distance
Sorted Doubly Linked List to Balanced BST
Minimized Maximum of Products Distributed to Any Store