# Arup Guha
# 6/1/2023
# Solution to NAC 2023 Problem A: Allergen Testing

# Returns the solution for a given n and d.
def solve(n,d):

    s = 0
    cur = 1

    # We're looking for the smallest s such that d+1 to the power s
    # is n or greater.
    while cur < n:
        cur *= (d+1)
        s += 1
    return s

# Process cases.
def main():
    nC = int(input())

    for loop in range(nC):

        toks = input().split()
        n = int(toks[0])
        d = int(toks[1])
        print(solve(n,d))

main()



   


