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;
struct number {
  int a[22] = {};
  void se(long long int b, int i) {
    for (int j = i; j < 22; j++) {
      a[j] += b % 10;
      b /= 10;
    }
  }
  void mol(struct number m) {
    int b[23] = {};
    for (int j = 0; j < 22; j++) {
      for (int k = 0; k < 22; k++) {
        if (k + j < 22) {
          b[k + j] += a[k] * m.a[j];
        }
      }
    }
    for (int k = 0; k < 22; k++) {
      a[k] = b[k] % 10;
      b[k + 1] += b[k] / 10;
    }
  }
  void mul(long long int n) {
    int b[23] = {};
    for (int j = 0; j < 22; j++) {
      b[j] = a[j] * n;
    }
    for (int j = 0; j < 22; j++) {
      a[j] = b[j] % 10;
      b[j + 1] += b[j] / 10;
    }
  }
};
long long int p10[63];
long long int p2[63];
long long int p5[63];
struct number po[22];
struct number po1(long long int n) {
  if (n == 0) {
    struct number h;
    h.a[0] = 1;
    return h;
  }
  struct number m = po1(n / 2);
  m.mol(m);
  m.mul((n % 2) + 1);
  return m;
}
void print(struct number v) {
  for (int j = 21; j >= 0; j--) cout << v.a[j];
  cout << endl;
}
void solve() {
  p5[0] = 1, p10[0] = 1, p2[0] = 1;
  for (int j = 1; j < 25; j++)
    p5[j] = p5[j - 1] * 5, p10[j] = p10[j - 1] * 10, p2[j] = p2[j - 1] * 2;
  long long int n;
  cin >> n;
  int v = 11;
  long long int rem = (p5[11] * n) % p2[11];
  if (rem < 0) rem += p2[11];
  long long int b = 0;
  if ((p2[11] - rem) % 5 == 0)
    b = 2 * p2[11] - rem;
  else
    b = p2[11] - rem;
  struct number fan;
  fan.se(n, 11);
  fan.se(b * p2[v], 0);
  fan.mul(1);
  struct number an;
  an.a[0] = 1;
  long long int u = 1;
  long long int x = 1;
  long long int poo = 0;
  for (int j = 0; j < 22; j++) {
    for (int k = 0; k < 10; k++) {
      if (an.a[j] == fan.a[j]) break;
      an.mol(po[j]);
      poo += u;
    }
    if (u == 1)
      u *= 4;
    else
      u *= 5;
  }
  cout << poo << endl;
}
int main() {
  long long int u = 1;
  for (int j = 0; j < 22; j++) {
    po[j] = po1(u);
    if (u == 1)
      u *= 4;
    else
      u *= 5;
  }
  int n;
  cin >> n;
  for (int j = 0; j < n; j++) solve();
  return 0;
}