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

t=input()
while t:
	n=input()
	while 1:
		flag=0
		n=bin(n)[2:]
		for i in range(1,len(n)):
#			print n[i-1]+"\t"+n[i]
			if ((n[i] is '1') and (n[i-1]==n[i])):
				flag=1
				break
		n=int(n,2)
		if flag==1:	
			n+=1
		else:
			print n
			break
	t-=1