for _ in range(int(input())): N=int(input()) X=0 Y=0 if bin(N).count('1')==1: N-=1 for i in reversed(range(64)): if N&(2**i)>0: if X<=Y: X+=1<