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

def consOnes(n):
	last=n%2
	n/=2
	while n:
		#print n, last
		if last and last==n%2: return 0
		last=n%2
		n/=2
	return 1	
t=input()
for _ in range(t): 
	n=input()
	while not consOnes(n): n+=1
	print n