In a car factory each car needs to go through k stages in order to be ready for sale, and each stage needs one day to be completed.
The process in the factory goes as follows. On the first day a car enters the first stage. On the second day a car moves from the first stage to the second stage, and a new car enters the first stage. On the third day a car moves from the second stage to the third stage, a car moves from the first stage to the second stage, and a new car enters the first stage, and so on. After k days (i.e. k stages) the car will be ready for sale.
Your task is simple, given the number of stages for each car to be ready, and the number of cars to be manufactured. How many days are needed to finish manufacturing all the cars?
The first line of the input contains an integer T (1 ≤ T ≤ 1000), where T is the number of the test cases.
Each test case has one line that contains two integers n and k (1 ≤ n, k ≤ 109), the number of cars to be manufactured and the number of stages each car requires.
For each test case, print a single integer that represents the number of required days to manufacture all the cars.
4
1 1
2 3
4 3
14526 78965
1
4
6
93490
Let's solve the third case to show how the process goes in the factory:
Name |
---|