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

for t in range(input()):
	n=int(raw_input())
	i=n
	while 1:
		s=bin(i)[2:]
		flag=1
		for j in range(0,len(s)-1,1):
			if s[j]=='1' and s[j+1]=='1':
				flag=0
				break
		if flag==1:
		 print i
		 break
		i=i+1