local q = io.read("*n") for i = 1, q do local n, k = io.read("*n", "*n") if k == 1 then print(n - 1) else local d = 0 local c = 1 local mul = 1 while c < n do mul = mul * k c = c + mul d = d + 1 end print(d) end end