"""
Allergen Testing

Say we have k sites. Each site has (d + 1) states: it either becomes active on
some day or never becomes active. Therefore we can distinguish (d + 1)^k
compounds. Use a language with bigints like python or take care with overflow
in C/C++.
"""
def main():
    t = int(input())
    for _ in range(t):
        n, d = map(int, input().split())
        k = 0
        cur = 1
        while cur < n:
            k += 1
            cur *= d + 1

        print(k)


if __name__ == "__main__":
    main()
