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;
const int maxK = 19;
long long pw2[maxK], pw5[maxK], pw10[maxK];
long long sum(long long a, long long b, long long mod) {
  long long s = a + b;
  if (s >= mod) s -= mod;
  return s;
}
long long mult(long long a, long long b, long long mod) {
  if (b == 0) return 0;
  if (b & 1) return sum(a, mult(a, b - 1, mod), mod);
  long long res = mult(a, b / 2, mod);
  return sum(res, res, mod);
}
long long pw(long long a, long long b, long long mod) {
  if (b == 0) return 1;
  if (b & 1) return mult(a, pw(a, b - 1, mod), mod);
  long long res = pw(a, b / 2, mod);
  return mult(res, res, mod);
}
long long get(long long res, long long cnt) {
  if (cnt == 1) {
    for (int i = 0; i <= 4; i++) {
      if (pw2[i] % 5 == res) return i;
    }
  }
  long long res_small = res % pw5[cnt - 1];
  long long md = get(res_small, cnt - 1);
  long long coef = pw(2, 4 * pw5[cnt - 2], pw5[cnt]);
  long long cur = pw(2, md, pw5[cnt]);
  long long now = md;
  for (int i = 0; i <= 4; i++) {
    if (cur == res) return now;
    cur = mult(cur, coef, pw5[cnt]);
    now += 4 * pw5[cnt - 2];
  }
  assert(0);
}
void solve() {
  long long x;
  cin >> x;
  long long q = pw2[12] - mult(x % pw2[12], pw5[6] % pw2[12], pw2[12]);
  long long num = x * pw10[6] + q * pw2[6];
  if (num % 5 == 0) {
    num += pw2[18];
  }
  long long s = (num / pw2[18]) % pw5[18];
  cout << get(s, 18) + 18 << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  pw2[0] = 1;
  pw5[0] = 1;
  pw10[0] = 1;
  for (int i = 1; i < maxK; i++) {
    pw2[i] = 2 * pw2[i - 1];
    pw5[i] = 5 * pw5[i - 1];
    pw10[i] = 10 * pw10[i - 1];
  }
  int tst;
  cin >> tst;
  for (int i = 1; i <= tst; i++) {
    solve();
  }
  return 0;
}