The Fibonacci sequence $F_0, F_1, \ldots$ is a special infinite sequence of non-negative integers, where $F_0 = 0$, $F_1 = 1$ and for each integer $n \ge 2$, $F_n = F_{n-1} + F_{n-2}$.
Consider the sequence $D$ of the last decimal digits of the first $N$ Fibonacci numbers, i.e. $D = (F_0 \% 10, F_1 \% 10, \ldots, F_{N-1} \% 10)$. Now, you should perform the following process:
- Let $D = (D_1, D_2, \ldots, D_l)$.
- If $l = 1$, the process ends.
- Create a new sequence $E = (D_2, D_4, \ldots, D_{2 \lfloor l/2 \rfloor})$. In other words, $E$ is the sequence created by removing all odd-indexed elements from $D$.
- Change $D$ to $E$.
When this process terminates, the sequence $D$ contains only one number. You have to find this number.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains a single integer $N$.

-----Output-----
For each test case, print a single line containing one integer ― the last remaining number.

-----Constraints-----
- $1 \le T \le 10^5$
- $1 \le N \le 10^{18}$

-----Subtasks-----
Subtask #1 (20 points):
- $1 \le T \le 10^5$
- $1 \le N \le 10^7$
Subtask #2 (80 points): original constraints

-----Example Input-----
1
9

-----Example Output-----
3

-----Explanation-----
Example case 1: The first $N$ Fibonacci numbers are $(0, 1, 1, 2, 3, 5, 8, 13, 21)$. The sequence $D$ is $(0, 1, 1, 2, 3, 5, 8, 3, 1) \rightarrow (1, 2, 5, 3) \rightarrow (2, 3) \rightarrow (3)$.

Starter code:

Solutions:
import math

t = int(input())

a = [-1, 0, 1]

for i in range(58):
 temp = a[-1] + a[-2]
 temp = temp%10
 a.append(temp)
 
for _ in range(t):
 n = int(input())
 
 temp = len(bin(n)) - 3
 temp = 2**temp
 temp = temp%60
 
 print(a[temp])

import math

def logBase2(n):
 res = 0
 fact = 1
 while((fact << (res+1)) <= n):
  res+=1
 return res

t = int(input())

a = [-1, 0, 1]

for i in range(58):
 temp = a[-1] + a[-2]
 temp = temp%10
 a.append(temp)
for _ in range(t):
 n = int(input())
 
 n = 1<<int(math.log2(n))
 
 print(a[n%60]) 


import math

def logBase2(n):
 res = 0
 fact = 1
 while((fact << (res+1)) <= n):
  res+=1
 return res

t = int(input())

a = [-1, 0, 1]

for i in range(58):
 temp = a[-1] + a[-2]
 temp = temp%10
 a.append(temp)
for _ in range(t):
 n = int(input())
 
 n = 1<<logBase2(n)
 
 print(a[n%60]) 


import math

t = int(input())

a = [-1, 0, 1]

for i in range(58):
 temp = a[-1] + a[-2]
 temp = temp%10
 a.append(temp)

for _ in range(t):
 n = int(input())
 
 n = math.floor(math.log(n, 2))
 n = (2**n)%60
 print(a[n])


import math

t = int(input())

a = [-1, 0, 1]

for i in range(61):
 temp = a[-1] + a[-2]
 temp = temp%10
 a.append(temp)
 
for _ in range(t):
 n = int(input())
 
 n = int(math.log(n, 2))
 
 n = (2**n)%60
 print(a[n])


import math
def fib(n):
 if n<2:
  return n
 dp = [0]*(n+1)
 dp[1] = 1
 for i in range(2, n+1):
  dp[i] = (dp[i-1] + dp[i-2]) % 10;
 # print(n, dp)  
 return dp[n]
 
t=int(input())

for _ in range(t):
 n = int(input())
 exp = int(math.floor(math.log(n, 2)))
 arg = (2**exp -1) % 60
 
 print( fib(arg) )

import math
def r(n):
 cycle = 60
 index = (1 << len(bin(n))-3) % cycle
 cur = 0
 next = 1 
 for i in range(1, index):
  nextNext = (cur + next) % 10
  cur = next
  next = nextNext
 return cur


t = int(input())
for i in range(t):
 c = int(input())
 print(r(c))

import math
def r(n):
 cycle = 60
 index = (1 << int(math.floor(math.log2(n)))) % cycle
 cur = 0
 next = 1 
 for i in range(1, index):
  nextNext = (cur + next) % 10
  cur = next
  next = nextNext
 return cur


t = int(input())
for i in range(t):
 c = int(input())
 print(r(c))

import math

t = int(input())

a = [-1, 0, 1]

for i in range(58):
 temp = a[-1] + a[-2]
 temp = temp%10
 a.append(temp)
 
for _ in range(t):
 n = int(input())
 
 n = int(math.log(n, 2))
 
 n = (2**n)%60
 print(a[n])

def fib(n):
 index = -1
 while n > 0:
  index += 1
  n = n // 2
 return index


first60Sequence = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

test = int(input())
for i in range(test):
 number = int(input())
 respectiveIndex = (2 ** fib(number)) % 60
 print(first60Sequence[respectiveIndex - 1])

# cook your dish here
def f(n):
 i=-1
 
 while n>0:
  i+=1
  n=n//2
 
 return i

fo= [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

l = int(input())

for _ in range(l):
 n = int(input())
 d = (2**f(n))%60
 print(fo[d-1])


# cook your dish here
def f(n):
 i=-1
 
 while n>0:
  i+=1
  n=n//2
 
 return i

fo= [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

l = int(input())

for _ in range(l):
 n = int(input())
 d = (2**f(n))%60
 print(fo[d-1])


# cook your dish here
# cook your dish here

def fib(n):
 i=-1
 
 while n>0:
  i+=1
  n=n//2
 
 return i

fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

t = int(input())

for _ in range(t):
 n = int(input())
 d = (2**fib(n))%60
 print(fl[d-1])
 #print(d)


# cook your dish here

def fib(n):
 i=-1
 
 while n>0:
  i+=1
  n=n//2
 
 return i

fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

t = int(input())

for _ in range(t):
 n = int(input())
 d = (2**fib(n))%60
 print(fl[d-1])
 #print(d)


# cook your dish here
fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

def log2(num) :
 i = -1
 while num>0 :
  i+=1
  num//=2
 return i

cycle = 60
for _ in range(int(input())) :
 n = int(input())
 target = (2**(log2(n)))%60
 print(fl[target-1])

# cook your dish here
fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

def log2(num) :
 i = -1
 while num>0 :
  i+=1
  num//=2
 return i

cycle = 60
for _ in range(int(input())) :
 n = int(input())
 target = (2**(log2(n)))%60
 print(fl[target-1])

# cook your dish here
fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

def log2(num) :
 i = -1
 while num>0 :
  i+=1
  num//=2
 return i

cycle = 60
for _ in range(int(input())) :
 n = int(input())
 target = (2**(log2(n)))%60
 print(fl[target-1])

# cook your dish here
fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

def log2(num) :
 i = -1
 while num>0 :
  i+=1
  num//=2
 return i

cycle = 60
for _ in range(int(input())) :
 n = int(input())
 target = (2**(log2(n)))%60
 print(fl[target-1])

# cook your dish here
fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

def log2(num) :
 i = -1
 while num>0 :
  i+=1
  num//=2
 return i

cycle = 60
for _ in range(int(input())) :
 n = int(input())
 target = (2**(log2(n)))%60
 print(fl[target-1])

# cook your dish here
fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

def log2(num) :
 i = -1
 while num>0 :
  i+=1
  num//=2
 return i

cycle = 60
for _ in range(int(input())) :
 n = int(input())
 target = (2**(log2(n)))%60
 print(fl[target-1])

# cook your dish here
fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

def log2(num) :
 i = -1
 while num>0 :
  i+=1
  num//=2
 return i

cycle = 60
for _ in range(int(input())) :
 n = int(input())
 target = (2**(log2(n)))%60
 print(fl[target-1])

# cook your dish here
fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

def log2(num) :
 i = -1
 while num>0 :
  i+=1
  num//=2
 return i

cycle = 60
for _ in range(int(input())) :
 n = int(input())
 target = (2**(log2(n)))%60
 print(fl[target-1])

# cook your dish here

def fib(n):
 i=-1
 
 while n>0:
  i+=1
  n=n//2
 
 return i

fl = [ 0, 1, 1, 2, 3, 5, 8, 3, 1, 4, 5, 9, 4, 3, 7,
  0, 7, 7, 4, 1, 5, 6, 1, 7, 8, 5, 3, 8, 1, 9,
  0, 9, 9, 8, 7, 5, 2, 7, 9, 6, 5, 1, 6, 7, 3,
  0, 3, 3, 6, 9, 5, 4, 9, 3, 2, 5, 7, 2, 9, 1]

t = int(input())

for _ in range(t):
 n = int(input())
 d = (2**fib(n))%60
 print(fl[d-1])
 #print(d)