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

t=input()
for j in range(t):
    n=input()
    check=False
    while not check:
       # print n
        x="{0:b}".format(n)
       # print x,type(x)
        ans=True
        
        for i in range(1,len(x)):
            #print "sa",x[i],x[i-1]
            if x[i]=="1" and x[i-1]=="1":
                #print "hi"
                ans=False
                break

        if ans==False:
            n+=1
            continue
        else:
            print n
            check=True
            continue