Q=int(input()) ans=[] for i in range(Q): N,K=map(int,input().split()) seg=0 k_num=1 while(N>k_num): k_num+=K K=K**(seg+1) seg+=1 ans.append(seg) for a in range(Q): print(ans[a])