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;
int get() {
  char ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  if (ch == '-') {
    int s = 0;
    while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
    return -s;
  }
  int s = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
  return s;
}
const long long Mod = 762939453125ll;
const int B = 873500;
long long Inv;
long long add(long long x, long long y, long long mo = Mod) {
  return x + y >= mo ? x + y - mo : x + y;
}
long long multi(long long x, long long y, long long mo = Mod) {
  long long ret = 0;
  if (x < y) swap(x, y);
  for (; y; y /= 2, x = add(x, x, mo))
    if (y & 1) ret = add(ret, x, mo);
  return ret;
}
long long quickmi(long long x, long long tim, long long mo) {
  long long ret = 1;
  for (; tim; tim /= 2, x = multi(x, x, mo))
    if (tim & 1) ret = multi(ret, x, mo);
  return ret;
}
long long getk(long long x) {
  long long phi = 1, ret = 0, now = 1, mo = 1;
  for (int s = 1; s <= 17; s++) {
    mo = mo * 5;
    long long ad = quickmi(2, phi, mo);
    long long v = quickmi(2, ret, mo);
    for (int c = 0; c <= 4; c++) {
      if (v == x % mo) break;
      ret += phi;
      v = multi(v, ad, mo);
    }
    if (s == 1)
      phi = 4;
    else
      phi = phi * 5;
  }
  return ret;
}
void solve() {
  long long a;
  cin >> a;
  int n = 1;
  for (long long now = 10; now <= a; now *= 10, n++)
    ;
  int m = 17 - n;
  long long n2 = 1, m2 = 1;
  long long m10 = 1;
  for (int i = 1; i <= n; i++) n2 = n2 * 2;
  for (int i = 1; i <= m; i++) m2 = m2 * 2, m10 = m10 * 10;
  long long b = a % n2;
  for (int i = 1; i <= m; i++) b = multi(b, 5, n2);
  b = (n2 - b) % n2;
  b = b * m2;
  long long ad = 1;
  for (int i = 1; i <= n + m; i++) ad = ad * 2;
  while ((a * m10 + b) % 5 == 0) b = b + ad;
  long long x = a * m10 + b;
  x = x / ad;
  cout << getk(x) + n + m << endl;
}
int main() {
  for (int T = get(); T; T--) solve();
  return 0;
}