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

t=int(raw_input())
while(t!=0):
    n=int(raw_input())
    fc=0
    while fc!=1:
        c=bin(n)
        d=str(c[2:])
        flag=0
        #print d
        for i in range(len(d)-1):
            #print "d[i]",d[i]
            #print "d[i+1]",d[i+1]
            if (int(d[i])==1 and int(d[i+1])==1):
                flag=1
                #print flag
                break
            else:
                flag=0
                #print flag
        #print flag
        if flag==1:
            n=n+1
            fc=0
        else:
            print n
            fc=1
            
    t=t-1