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

__author__ = 'pjha'

def main():


    s=input()
    for i in range(1,s+1):
        a=input()

        num="{0:b}".format(a)
        while('11' in num):
            a=a+1
            num="{0:b}".format(a)
        print a








if __name__ == '__main__':
    main()