Problem: You are given n positive integers a1, a2, ..., an.

For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Here length(m) is the length of the decimal notation of m.

Note that you don't have to minimize ki. The decimal notations in this problem do not contain leading zeros.

Input

The first line contains a single integer n (1 ≤ n ≤ 2 000) — the number of integers ai.

Each of the next n lines contains a positive integer ai (1 ≤ ai < 1011).

Output

Print n lines. The i-th of them should contain a positive integer ki such that the last min(100, length(2ki)) digits of 2ki contain the decimal notation of ai as a substring. Integers ki must satisfy 1 ≤ ki ≤ 1050.

It can be shown that the answer always exists under the given constraints. If there are multiple answers, print any of them.

Examples

Input

2
8
2


Output

3
1


Input

2
3
4857


Output

5
20

Solution (in PYTHON3):

Solution:
m10=10000000000
mp=21
p2=2**mp

def qmd(log, md):
    ans=1
    a=2
    while log>0:
        if log%2:
            ans=ans*a%md
        log=log//2
        a=a*a%md
    return ans

n=int(input())
for nn in range(n):
    a=int(input())
    #print(a)
    x=a*m10//p2*p2+p2
    while x%5==0:
        x+=p2
    #print(x)
    
    log=0
    while 2**log%5!=x%5:
        log+=1
    #print(log)

    md=5
    phi=4
    for i in range(1, mp):
        md*=5
        #print(x%md)
        while qmd(log,md)!=x%md:
            log+=phi
            #print('log'+str(log))
        phi*=5

    if log<mp:
        log+=phi

    print(log)
    #print(qmd(log,10**mp))