R=range I=input for t in R(int(I())): N=int(I());l=r=-1 for d in R(31): if N>>d&1: if l<0:l=d else:r=d-l;break print(-1 if l<0 or r<0else((1<