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 PYTHON):

Solution:
n = int(raw_input())

def fastexp(x,e,m):
    X = x
    E = e
    Y = 1
    while E > 0:
        if E % 2 == 0:
            X = (X * X) % m
            E = E/2
        else:
            Y = (X * Y) % m
            E = E - 1
    return Y

def f(a):
    l = len(str(a))
    k = 1
    cur = 5
    p = 2**l
    while cur <= 3*p:
        k += 1
        cur *= 5
    res = (-a * 10**k) % 2**(k+l)
    if res % 5 == 0:
        res += 2**(k+l)
    targ = 10**k * a + res
    t = targ % 5
    solved = 1
    if t == 1:
        x = 0
    elif t == 2:
        x = 1
    elif t == 4:
        x = 2
    elif t == 3:
        x = 3
    else:
        return "DIV BY 5 ISSUE"
    curphi = 4
    curtest = 25
    while solved <= k+l:
        x1 = x
        x2 = x1 + curphi
        x3 = x2 + curphi
        x4 = x3 + curphi
        x5 = x4 + curphi
        if (fastexp(2, x1, curtest) - targ) % curtest == 0:
            x = x1
            solved += 1
            curphi *= 5
            curtest *= 5
        elif (fastexp(2, x2, curtest) - targ) % curtest == 0:
            x = x2
            solved += 1
            curphi *= 5
            curtest *= 5
        elif (fastexp(2, x3, curtest) - targ) % curtest == 0:
            x = x3
            solved += 1
            curphi *= 5
            curtest *= 5
        elif (fastexp(2, x4, curtest) - targ) % curtest == 0:
            x = x4
            solved += 1
            curphi *= 5
            curtest *= 5
        elif (fastexp(2, x5, curtest) - targ) % curtest == 0:
            x = x5
            solved += 1
            curphi *= 5
            curtest *= 5
    while x < k+l:
        x += curphi
    return x

for i in xrange(n):
    a = int(raw_input())
    print f(a)