In a bizarre game of chess ,knight was so drunk, that instead of his usual move he started walking straight. In every move Knight jumps on 2n steps forward (n is number of block that he had travelled so far from starting) but after that he has to take either 1 step forward or backward.
Now the Knight needs to get to position X so King (i.e. You) needs to decide the order of his backward or forward step in such a way that he can reach its destination in minimum number of steps. Remember he always travels in a straight line and the length of the board is infinite.

-----Input-----
The first line of the input contains an integer T denoting the number of test cases, for each test case enter value X ( i.e. destination)
Note : initially knight is at n = 1.

-----Output-----
For each test case the output should be string of numbers 1 & 2 where 1 denotes backward step and 2 denote the forward step 
Note : for no solution print 0.

-----Constraints-----
- 1 ≤ T ≤ 100
- 1 ≤ X ≤ 10^10

-----Example-----
Input:
2
17
10
Output:
2111
0

-----Explanation-----
Case 1 : starting from  n = 1 , knight moves to n = 3 ('2') , 5 ('1') , 9 ('1') , 17 ('1') i.e. string printed is 2 1 1 1
Case 2 : no solution is possible

Starter code:

Solutions:
from math import log,pow
n=int(input())
a=[]
for i in range(n):
 no=int(input())
 if(no%2==0):
  a.append("0")
 elif(no==1):
  a.append("1")
 elif(no==3):
  a.append("3")
 else:
  s="2"
  lv=int(log(no,2))
  clv=1
  cno=3
  while(cno!=no):
   if(no<cno*pow(2,lv-clv)):
    s=s+"1"
    clv=clv+1
    cno=(2*cno)-1
   else:
    s=s+"2"
    clv=clv+1
    cno=(2*cno)+1
  a.append(s)
for i in a:
 print(i)
 


import sys

def main():
 t = int(input())
 for i in range(t):
  n = int(input())
  if n % 2 == 0:
   print("0")
  else:
   str = ""
   possible = 1
   while n != 1:
    if ((n - 1) / 2) % 2 == 1:
     n = n - 1
     n = n / 2
     str += '2'
    elif ((n + 1) / 2) % 2 == 1:
     n += 1
     n = n / 2
     str += '1'
    else:
     possible = 0
   if not possible:
    print("0")
   else:
    output = ""
    for j in range(len(str)):
     output += str[len(str) - j - 1]
    print(output)

main()


t=int(input())
while t:
 x=int(input())
 ans=''
 if(x &1):
  cc=['2' if x =='1' else '1' for x in list(bin(x)[2:-1])]
  for x in cc:
   ans = ans + str(x)
  print(ans)
 else:
  print('0')
 t = t-1

tests=int(input())
while tests:
 x=int(input())
 ans=''
 if(x &1):
  cc=['2' if x =='1' else '1' for x in list(bin(x)[2:-1])]
  for x in cc:
   ans = ans + str(x)
  print(ans)
 else:
  print('0')
 tests = tests-1

tests=int(input())
while tests:
 x=int(input())
 ans=''
 if(x &1):
  cc=['2' if x =='1' else '1' for x in list(bin(x)[2:-1])]
  for x in cc:
   ans = ans + str(x)
  print(ans)
 else:
  print('0')
 tests = tests-1

t=int(input())
while t:
 x=int(input())
 ans=''
 if(x &1):
  cc=['2' if x =='1' else '1' for x in list(bin(x)[2:-1])]
  for x in cc:
   ans = ans + str(x)
  print(ans)
 else:
  print('0')
 t = t-1

t=int(input())
while t:
 x=int(input())
 ans=''
 if(x &1):
  cc=['2' if x =='1' else '1' for x in list(bin(x)[2:-1])]
  for x in cc:
   ans = ans + str(x)
  print(ans)
 else:
  print('0')
 t = t-1

t=int(input())
while t:
 x=int(input())
 ans=''
 if(x &1):
  cc=['2' if x =='1' else '1' for x in list(bin(x)[2:-1])]
  for x in cc:
   ans = ans + str(x)
  print(ans)
 else:
  print('0')
 t = t-1

t=int(input())
while t:
 x=int(input())
 ans=''
 if(x &1):
  cc=['2' if x =='1' else '1' for x in list(bin(x)[2:-1])]
  for x in cc:
   ans = ans + str(x)
  print(ans)
 else:
  print('0')
 t = t-1

t=int(input())
getBin = lambda x: x >= 0 and str(bin(x))[2:] or "-" + str(bin(x))[3:]
while(t):
 n=int(input())
 if(n%2==0):
  print(0)
 else:
  lst=[]
  arr=getBin(n)
  for i in range(0,len(arr)-1):
   if(arr[i]=='1'):
    lst.append("2")
   if(arr[i]=='0'):
    lst.append("1")
  print("".join(lst))
 t=t-1

t = eval(input())
for i in range(t):
 n = eval(input())
 if n%2 == 0:
  print("0")
 else:
  s = ""
  while n>3:
   if ((n+1)/2)%2==1:
    s+="1"
    n = (n+1)/2
   else:
    s+="2"
    n = (n-1)/2
  print("2"+s[::-1])