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