ATOMS - Atoms in the Lab

Mr. Yagami is a scientist in the Bhabha Atomic Research Centre. They are conducting a lab experiment on nuclear fission. In nuclear fission, one atom breaks into more than one atom of the same type.

Initially, there are N atoms in the lab. Starting from now (t = 0), after each second, every atom will break into K atoms of the same type. They don’t want the number of atoms to exceed M, so they have to stop the reaction at some time t = T. Can you find this value T for Mr. Yagami.

Input

First line contains P, the number of test cases. Next P lines contain three integers each. These three integers represent the values of N, K and M respectively.

Output

For each test case print the time at which the reaction will have to be stopped.

Constraints

1 ≤ P ≤ 10^4
2 ≤ N, K, M ≤ 10^18

Example

Input:
2
2 2 7
2 2 8

Output:
1
2

Explanation

1st test case:

  • at t=1, number of atoms will be 4.
  • at t=2, number of atoms will be 8.

So reaction has to be stopped at t=1.

2nd test case:

  • at t=1, number of atoms will be 4.
  • at t=2, number of atoms will be 8.
  • at t=3, number of atoms will be 16.


Problem Setter: Lalit Kundu


Added by:darkshadows
Date:2014-01-26
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

hide comments
2014-04-05 21:54:05 humble_coder
if n<m then print 0 , cost me 2 WA for this.
2014-03-24 04:59:43 Pradyumna Newalkar
can someone please tell why using log() would give WA?
2014-03-23 19:52:13 Anubhav Balodhi
still getting wa 0.o
I don't know what's wrong with my submitted code... and even bigInt fails for this...
finally AC, goto: lab.
@Gravity log gives approximate results, and the range of n,k,m is for 64 bit long long... hence use other functions from math.h

Last edit: 2014-03-26 07:27:40
2014-03-05 15:42:56 Michoooool
more test cases plz ??
2014-03-03 17:09:16 innovolt
log() failed bt AC with user defined power()
2014-02-24 07:56:10 ivar.raknahs
getting error in 4th test case.
help
2014-02-19 19:14:10 californiagurl
OMG!!! got so many WA bcz i overlooked the range for m,n,k.....looks like i'll need an array
2014-02-08 09:11:23 Rishav Goyal
would be better if u don't allow python submission :)
2014-02-08 09:11:23 deepak gautam
i am getting WA can any one please reply which case not satisfy..


=>don't post any code here.
it's overflow

Last edit: 2014-02-06 10:00:34
2014-02-08 09:11:23 napster
My 100th AC....:)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.