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

for _ in range(int(raw_input())):
	n = int(raw_input())
	s = bin(n)[2:]
	p = s.find("11")
	while p != -1:
		if p == 0:
			s = "1" + len(s) * "0"
			break
		s = s[:p - 1] + "1" + (len (s) - p) * "0"
		p = s.find("11")
	print int(s, 2)