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>
using std::cin;
using std::cout;
const long long mod = 762939453125ll, iv2 = 381469726563ll,
                iv4 = 572204589844ll, iv8 = 286102294922ll,
                iv16 = 143051147461ll;
const long long step[17] = {0ll,
                            143051147461ll,
                            518550950801ll,
                            713454200876ll,
                            289665379376ll,
                            120490959376ll,
                            609681359376ll,
                            177313046876ll,
                            62590625001ll,
                            312953125001ll,
                            38886718751ll,
                            194433593751ll,
                            209228515626ll,
                            283203125001ll,
                            653076171876ll,
                            213623046876ll,
                            305175781251ll};
long long PowerMod(long long a, int n, long long c = 1) {
  for (; n; n >>= 1, a = a * a % mod)
    if (n & 1) c = c * a % mod;
  return c;
}
inline long long MulMod(long long a, long long b, long long m) {
  long long t = (a * b - (long long)((long double)a * b / m) * m) % m;
  return t + (t >> 63 & m);
}
long long PowerMod(long long a, long long n, long long m) {
  if (!n || a == 1) return 1ll;
  long long s = PowerMod(a, n >> 1, m);
  return s = MulMod(s, s, m), n & 1 ? MulMod(s, a, m) : s;
}
long long pohlig_hellman(long long n) {
  int i;
  long long bs = -1, pw = 4, expo = 30517578125ll;
  switch (n % 5) {
    case 1:
      bs = 0;
      break;
    case 2:
      bs = 1, n = MulMod(n, iv2, mod);
      break;
    case 3:
      bs = 3, n = MulMod(n, iv8, mod);
      break;
    case 4:
      bs = 2, n = MulMod(n, iv4, mod);
      break;
  }
  assert(~bs);
  for (i = 1; i < 17; ++i, pw *= 5, expo /= 5)
    for (; PowerMod(n, expo, mod) != 1; n = MulMod(n, step[i], mod), bs += pw)
      ;
  return bs;
}
void work() {
  long long n;
  cin >> n, n = ((n * 1000000 - 1) | 131071) + 1;
  n = (n >> 17) + !(n % 5);
  cout << pohlig_hellman(n) + 17 << '\n';
}
int main() {
  int T;
  std::ios::sync_with_stdio(false), cin.tie(NULL);
  for (cin >> T; T; --T) work();
  return 0;
}