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 <typename _T>
inline void read(_T &f) {
  f = 0;
  _T fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') {
      fu = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + (c & 15);
    c = getchar();
  }
  f *= fu;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + 48);
  else
    print(x / 10), putchar(x % 10 + 48);
}
template <typename T>
void print(T x, char t) {
  print(x);
  putchar(t);
}
int T, n;
long long a;
long long mul(long long x, long long y, long long md) {
  long long ans = 0;
  while (y) {
    if (y & 1) ans = (ans + x) % md;
    y >>= 1;
    x = (x + x) % md;
  }
  return ans;
}
long long fpow(long long x, long long y, long long md) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = mul(ans, x, md);
    y >>= 1;
    x = mul(x, x, md);
  }
  return ans;
}
int main() {
  read(T);
  while (T--) {
    read(a);
    long long tmp = a;
    n = 0;
    while (tmp) tmp /= 10, ++n;
    for (long long m = 1, pw = 10;; ++m, pw *= 10) {
      long long md = 1ll << (n + m);
      long long b = (md - a * pw % md) % md;
      if (b % 5 == 0) b += md;
      if (b >= pw) continue;
      long long x = (a * pw + b) / md, mi = 0, phi = 4, pw5 = 5;
      for (int i = 0; i <= 4; i++) {
        if (fpow(2, i, 5) == x % 5) {
          mi = i;
          break;
        }
      }
      for (int i = 2; i <= n + m; i++) {
        if (i != 2) phi *= 5;
        pw5 *= 5;
        for (int j = 0; j <= 4; j++) {
          if (fpow(2, mi + phi * j, pw5) == x % pw5) {
            mi += phi * j;
            break;
          }
        }
      }
      print(mi + n + m, '\n');
      break;
    }
  }
  return 0;
}