You have c number of chocolates that you want to distribute between your n students. The intelligence level of the students is not the same, therefore, you decide to distribute the chocolates in such a way that a smarter student gets strictly more chocolates than the ones who are less smarter.
The difference between the chocolates received by any two adjacent students must be exactly one. Formally, if the least intelligent student gets k chocolates, then others must get k+1, k+2, k+3,.... At the same time, your task is to minimize the number of chocolates that are left (if any) after distributing those among students. Determine the minimum number of chocolates left.
Note
Input format
Output format
For each test case, print the minimum number of chocolates left in a new line.
Constraints
1≤T≤1051≤c≤10181≤n≤109
In the first test case the 3 sutdents will get 5, 6, 7 chocolates. This will make the total count to 18. Thus 20 - 18 = 2 chocolates remain.
In the second test case, there is no valid way to distribute the chocolates. So all the chocolates remain.