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

n=input()
for _ in range(n):
	num=input()
	ans=1
	if num&(num-1)==0:print num
	elif num&(num*2)==0:print num
	elif num&(num+1)==0:print num+1
	else:
		while num&(num<<1)!=0:
			num+=1
		print num