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 namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
template <class T>
inline void umin(T &x, T y) {
  x = x < y ? x : y;
}
template <class T>
inline void umax(T &x, T y) {
  x = x > y ? x : y;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
long long a, mi10[66], mi2[66], f[66], phi[66];
int n, m;
inline long long mul(long long a, long long n, long long mo) {
  if (a < n) swap(a, n);
  long long res = 0;
  assert(n >= 0);
  while (n) {
    if (n & 1) res = res + a < mo ? res + a : res + a - mo;
    a = a + a < mo ? a + a : a + a - mo;
    n >>= 1;
  }
  return res;
}
inline long long power(long long a, long long n, long long mo) {
  long long res = 1;
  while (n) {
    if (n & 1) res = mul(res, a, mo);
    a = mul(a, a, mo);
    n >>= 1;
  }
  return res;
}
int getlen(long long x) {
  int res = 0;
  while (x) x /= 10, res++;
  return res;
}
int main() {
  mi10[0] = 1;
  for (register int i = (1); i <= (18); i++) mi10[i] = 10LL * mi10[i - 1];
  for (register int i = (0); i <= (60); i++) mi2[i] = 1ll << i;
  int T;
  read(T);
  while (T--) {
    read(a);
    n = getlen(a);
    m = (n + 2) / 2;
    long long x = (a + 1) * mi10[m];
    x -= x % mi2[n + m];
    if (x == (a + 1) * mi10[m]) x -= mi2[n + m];
    long long y = x >> n + m;
    if (y % 5 == 0) y--;
    f[0] = 1;
    static long long mi[66], phi[66];
    mi[0] = 1;
    for (register int i = (1); i <= (n + m); i++) mi[i] = mi[i - 1] * 5LL;
    phi[0] = 1;
    for (register int i = (1); i <= (n + m); i++) phi[i] = mi[i - 1] * 4;
    for (register int i = (0); i <= (n + m - 1); i++)
      for (register int j = (0); j <= (4); j++)
        if (y % mi[i + 1] == power(2, f[i] + phi[i] * j, mi[i + 1])) {
          f[i + 1] = f[i] + phi[i] * j;
          break;
        }
    assert(power(2, f[n + m], mi[n + m]) == y % mi[n + m]);
    printf("%lld\n", n + m + f[n + m]);
  }
  return 0;
}