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

Solution:
#include <bits/stdc++.h>
long long mul(long long x, long long y, long long mod) {
  long long ret = x * y - (long long)((long double)x * y / mod + 0.5) * mod;
  return ret + (ret >> 63 & mod);
}
long long pow(long long x, long long y, long long mod, long long ans = 1) {
  for (; y; y >>= 1, x = mul(x, x, mod))
    if (y & 1) ans = mul(ans, x, mod);
  return ans;
}
long long solve(long long n, int k, long long mod) {
  long long ret = 0, s = mod + 1 >> 1, t = 4, test = mod / 5;
  for (int i = 0; i <= 3; ++i) {
    if (pow(n, mod / 5, mod) == 1) {
      ret = i;
      break;
    }
    n = (n & 1 ? n + mod : n) >> 1;
  }
  s = mul(s, s, mod), s = mul(s, s, mod);
  for (int i = 0; i < k - 1; ++i) {
    test /= 5;
    for (int j = 0; j < 5; ++j) {
      if (pow(n, test, mod) == 1) break;
      ret += t, n = mul(n, s, mod);
    }
    s = pow(s, 5, mod), t *= 5;
  }
  return ret;
}
void solve() {
  long long x;
  std::cin >> x;
  int t = std::log10(x) + 1;
  long long q = 1, s = 1;
  for (int i = 0; i < t; ++i) s *= 5;
  for (int a = 0;; ++a) {
    long long mod = 1LL << a + t, b = (mod - x % mod) % mod;
    while (b < q) {
      if (b % 5) {
        long long ret = solve((x + b) % s, a + t, s);
        long long phi = std::max(s / 5 * 4, 1LL);
        while (ret < a + t) ret += phi;
        std::cout << ret << '\n';
        return;
      } else
        b += mod;
    }
    q *= 10, x *= 10, s *= 5;
  }
}
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  int tc;
  std::cin >> tc;
  while (tc--) solve();
  return 0;
}