for _ in range(int(input())): a=bin(int(input()))[2:] for i in reversed(range(len(a)-1)): if a[i]==a[i+1]=='1': print(pow(2,i)) break else: print(-1)