'''
Project Euler #2: Even Fibonacci numbers

Each new term in the Fibonacci sequence is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be:
1,2,3,5,8,13,21,34,55,89,...
By considering the terms in the Fibonacci sequence whose values do not exceed N,
find the sum of the even-valued terms.

Input Format

First line contains T that denotes the number of test cases.
This is followed by T lines, each containing an integer, N.

Constraints

1 ≤ T ≤ 10^5
10 ≤ N ≤ 4 x 10^16

Output Format

Print the required answer for each test case.

Sample Input 0

2
10
100

Sample Output 0

10
44

Explanation 0

For N=10, we have {2,8}, sum is 10.
For N=100, we have {2,8,34}, sum is 44.

'''
import sys

def fibonacci(n):
    a,b=0,1
    res=[]
    while(b<n):
        res.append(b)
        a,b=b,a+b
    del res[0]
    return res

t=int(input())
for i in range(t):
    N=int(input())
    nums=fibonacci(N)
    c=0
    for i in nums:
        if((i%10)%2==0):
            c+=i
    print(c)
