URI Online Judge | 2896

Enjoy the Offer

By Paulo E. D. Pinto, UERJ- Universidade do Estado do Rio de Janeiro BR Brazil

Timelimit: 1

A supermarket is doing a sales promotion for soft drinks. If one day you buy soft drinks and bring the empty bottles the next day, they exchange each set of K empty bottles for a full one. A customer wants to make the most of this offer and therefore bought several bottles on the first day of the promotion. Now he wants to know how many bottles he will have at the end of the second day of the promotion if he use it to the fullest.

Make a program to calculate this.


The first input line contains integer T (1 ≤ T ≤ 10000), which indicates the number of test cases. In each of the following T lines come two integers N and K (1 ≤ K, N ≤ 10000), respectively the number of soft drinks bought and the number of empty bottles to gain a full.


For each test case print the number of bottles that the customer will have on the second day, if he makes the most of the offer.

Input Sample Output Sample

7 4
4 7
4000 7