q = int(input()) nkq = [None] * q for i in range(q): nkq[i] = list(map(int, input().split(' '))) for nk in nkq: depth = 0 c = 0 while(True): c += nk[1] ** depth if c >= nk[0]: break depth += 1 print(depth)