When monkeys are given some fire-crackers, they have only one thing in the mind - to blow things up. Small boxes were easy to blow up, and thus mailboxes became a popular target.
Now, a small mailbox manufacturer is interested in how many fire-crackers his new mailbox prototype can withstand without exploding and has hired you to help him. He will provide you with k identical mailbox prototypes each fitting up to m fire-crackers. However, he is not sure of how many fire-crackers he needs to provide you with in order for you to be able to solve his problem, so he asks for your help.
The constraints are:
- If you blow up a mailbox, you can't use the mailbox again, so if you have only k = 1 mailboxes, you would have to start testing with 1 fire-cracker, then 2 fire-crackers, and so on until it finally exploded. In the worst case, that is if it does not blow up even when filled with m fire-crackers, you would need 1 + 2 + 3 + ... + m = m * (m + 1)/2 fire-crackers.
- If a mailbox can withstand x fire-crackers, it can also withstand x-1 fire-crackers.
- Upon an explosion, a mailbox is either totally destroyed (blown up) or unharmed, which means that it can be reused in another test explosion.
Now, the manufacturer wants you to find the maximum number of fire-crackers that his mailboxes can withstand. Before doing that you have to buy some fire-crackers to test that. So, you need to find the minimum number of fire-crackers you need to buy to test the mailboxes.
Input
Input starts with an integer T (≤ 10000), denoting the number of test cases.
Each case starts with a line containing two integers: k (1 ≤ k ≤ 100) and m (1 ≤ m ≤ 100).
Output
For each case, print the case number and the minimum number of fire-crackers you have to buy.
Sample
Sample Input | Sample Output |
---|---|
4 1 10 3 73 5 100 1 100 | Case 1: 55 Case 2: 382 Case 3: 495 Case 4: 5050 |