for _ in range(int(input())): N, K = map(int, input().split()) x = 1 j = 0 while N > x: x *= K x += 1 j += 1 print(j)