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

T = int(raw_input())

for i in range(0,T):
	n = int(raw_input())
	for j in range(n,100000):
		st = str(bin(j))
		
		for k in range(1,len(st)):
			if st[k] == '1' and st[k-1]=='1':
				break
		else :
			print j
			break