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 N = 2010;
long long mres = 0;
inline long long mul(long long a, long long b, long long m) {
  mres = 0;
  while (a > 0) {
    if (a & 1) {
      mres += b;
      if (mres >= m) mres -= m;
    }
    a >>= 1;
    b += b;
    if (b >= m) b -= m;
  }
  return mres;
}
long long fres = 1;
inline long long fastpower(long long num, long long po, long long m) {
  fres = 1;
  num %= m;
  while (po > 0) {
    if (po & 1) fres = mul(num, fres, m);
    po >>= 1;
    num = mul(num, num, m);
  }
  return fres;
}
long long pre = 0, m2 = 100000000000000000LL, cur, inc, tmpp;
long long l[19], ml[19], po[19];
int tmp, d = 6;
bool found;
vector<long long> arr;
vector<pair<long long, int> > ans;
long long p[N];
vector<int> m;
vector<int> v;
inline int getd(long long val, int i) { return ((val / po[i]) % 10); }
int main() {
  l[0] = 4;
  po[0] = 1;
  for (int i = 1; i < 19; i++) {
    l[i] = l[i - 1] * 5;
    po[i] = (long long)10 * po[i - 1];
  }
  for (int i = 0; i < 19; i++) {
    ml[i] = fastpower(2, l[i], m2);
  }
  cur = 1;
  for (int i = 0; i < l[d]; i++, cur += cur) {
    if (cur >= m2) cur -= m2;
    arr.push_back(cur);
  }
  int t;
  cin >> t;
  ans.resize(t);
  long long x;
  for (int i = 0; i < t; i++) {
    scanf("%lld", &ans[i].first);
    ans[i].second = i;
  }
  sort(ans.begin(), ans.end());
  int fr = 0, fv = 0, sx = 0;
  for (int it = 0; it < (int)ans.size(); it++) {
    if (it > 0 && ans[it].first == ans[it - 1].first) {
      p[ans[it].second] = p[ans[it - 1].second];
      continue;
    }
    v.clear();
    x = ans[it].first;
    while (x > 0) {
      v.push_back(x % 10);
      x /= 10;
    }
    pre = -1;
    for (int i = (v[0] == 0 ? 25 : 0); i < (int)arr.size(); i++) {
      for (d = 5; d <= 6; d++) {
        if (i >= l[d]) continue;
        tmp = getd(arr[i], d);
        if (tmp == v[0]) {
          cur = arr[i];
          pre = i;
          for (int idx = 1; idx < (int)v.size(); idx++) {
            found = false;
            if ((getd(cur, d + idx) & 1) != (v[idx] & 1)) {
              pre = -1;
              break;
            }
            for (int it = 0; it < 5; it++, pre += l[d + idx - 1],
                     cur = mul(cur, ml[d + idx - 1], m2)) {
              if (getd(cur, d + idx) != v[idx]) continue;
              found = true;
              break;
            }
            if (!found) {
              pre = -1;
              break;
            }
          }
        }
        if (pre != -1) {
          if (d == 4)
            fr++;
          else if (d == 5)
            fv++;
          else
            sx++;
          break;
        }
      }
      if (pre != -1) break;
    }
    assert(pre != -1);
    p[ans[it].second] = pre;
  }
  for (int i = 0; i < t; i++) {
    printf("%lld\n", p[i]);
  }
  return 0;
}