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

'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def fun(x):
	f=0
	s=0
	a=[]
	while(x):
		a.append(x%2)
		x=x/2
	c=map(str,a)
	x='11'
	v=''.join(c)
	if(x in v):
		return 0
	else:
		return 1
t=input()
for _ in range(0,t):
	n=input()
	while(1):
		if(fun(n)==1):
			print n
			break
		else :
			n+=1