JUMPBALL - THE JUMPING BALL

A ball is dropped from a height 'h' and it bounces at a bouncing constant 'b' i.e. the ball bounces back to a height that is 1/b times the height from which it was originally dropped. So given h and b we need to find the number of times the ball bounces before it comes to halt. Any height less than 1m can be considered as the halt.

Input

First line contains the number of test cases t. 1 <= t <= 100000.

The next 't' lines each contain 2 space separated integers 'h' and 'b'.

1 <= h <= 10^9

2 <= b <= 30

Output

For each test case output a single line containing the answer.

Example

Input:
2
8 2
2 9

Output:
3
0

Added by:cegprakash
Date:2013-01-20
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: BF GOSU

hide comments
2013-01-24 17:34:05 cegprakash
Yes. Your code will be tested against 100000's of test cases as given in the input constraints.
2013-01-24 17:32:50 KAVITHA
@cegprakash Eventhough i cross checked my code with ur sample inputs ...is it possible for my code to be wrong??
2013-01-24 15:36:31 cegprakash
"we need to find the number of times the ball bounces before it comes to halt"
So the problem statement is correct
2013-01-24 15:27:59 ash
<1 or <=1 ???
2013-01-24 15:25:28 cegprakash
yes
2013-01-24 15:22:50 Vignesh
how is the input given? through stdin?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.