R=range I=input for t in R(int(I())): N=int(I());x,l=0,31 for d in R(31): c=N>>d&1 if d>l+1and c<1:break elif(d>l)^c:l=d;x|=1<