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>
void debug_out(T t) {
  cerr << t;
}
template <typename A, typename B>
void debug_out(pair<A, B> u) {
  cerr << "(" << u.first << " " << u.second << ")";
}
template <typename T>
void debug_out(vector<T> t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << ", ";
  }
}
template <typename T>
void debug_out(vector<vector<T>> t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << endl;
  }
}
const int n = 20;
const int MAX = 11;
long long ten = 1, five = 1, two = 1;
inline long long mul(long long a, long long b, long long md) {
  a %= md;
  b %= md;
  long long res = 0;
  while (b) {
    if (b & 1) {
      res += a;
      if (res >= md) res -= md;
    }
    a = a * 2;
    if (a >= md) a -= md;
    b >>= 1;
  }
  return res;
}
long long solve(long long md) {
  long long res = 0;
  long long cur = 5;
  long long power = 1;
  long long base = 16;
  long long c = md % 5;
  for (int i = 0; i < 4; i++) {
    if ((power % cur) == c) {
      res = i;
      break;
    }
    power *= 2;
  }
  for (int i = 0; i < n - 1; i++) {
    cur *= 5;
    c = md % cur;
    bool ok = false;
    long long b = base;
    base = 1;
    for (int j = 0; j < 5; j++) {
      if (!ok && (power % cur) == c) {
        res += (cur / 25) * j * 4;
        ok = true;
      }
      if (!ok) power = mul(power, b, five);
      base = mul(base, b, five);
    }
    assert(ok);
  }
  return res;
}
inline long long power(long long a, long long b, long long md) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a, md);
    }
    a = mul(a, a, md);
    b >>= 1;
  }
  return res;
}
int main() {
  for (int i = 0; i < n; i++) {
    if (i < n - MAX) ten *= 10;
    five *= 5;
    two *= 2;
  }
  int iter;
  cin >> iter;
  while (iter--) {
    long long a;
    cin >> a;
    long long add = mul(a, ten, two);
    if (add > 0) add = two - add;
    a = mul(a, ten, five);
    a += add;
    if (a % 5 == 0) a += two;
    a = a % five;
    long long res = solve(a);
    cout << res + (five / 5) * 4 << endl;
  }
  return 0;
}