10
71
8497
6364
6530
9199
5754
1508
9388
6992
4494
72
8512
8192
8192
9216
8192
2048
9472
8192
4608

test=input()
test=int(test)
for j in range(0,test):
 N=input()
 N=int(N) 
 #bin_N=('{0:08b}'.format(N))
 ##N=N+1
 flag=-1
 while flag==-1 : 
  bin_N=('{0:08b}'.format(N))
  #print bin_N
  count=0
  len1=len(bin_N)
  for i in range(0,len(bin_N)-1) :
  #print bin_N[i]
   if bin_N[i]=="1"and bin_N[i+1]!="1":
       count=count+1
   elif bin_N[i]=="1"and bin_N[i+1]=="1":
      
       N=N+1
       break
   else:
      # print "Howdy"
      count=count+1 
      continue
  if count==len1-1 :   
   print (N)   
   flag=0