for _ in range(int(input())):
    P, R, F = [int(x) for x in input().split()]
    year = 0
    while P <= F:
        year += 1
        P *= R
    print(year)

dc1508a059b3ece6d9d2bcd584664a32ab2a398f
<mask token>

for _ in range(int(input())):
    P, R, F = [int(x) for x in input().split()]
    year = 0
    while P <= F:
        year += 1
        P *= R
    print(year)
