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 L = 40;
const int M = 30;
struct Num {
  int a[L];
  Num() {
    for (int i = 0; i < L; i++) a[i] = 0;
  }
  Num(int x) {
    for (int i = 0; i < L; i++) a[i] = 0;
    int len = 0;
    while (x > 0) {
      a[len++] = x % 10;
      x /= 10;
    }
  }
  Num operator+(const Num &A) const {
    Num R = Num();
    for (int i = 0; i < L; i++) R.a[i] = a[i] + A.a[i];
    for (int i = 0; i < L - 1; i++) {
      R.a[i + 1] += R.a[i] / 10;
      R.a[i] %= 10;
    }
    R.a[L - 1] %= 10;
    return R;
  }
  Num operator*(const Num &A) const {
    Num R = Num();
    for (int i = 0; i < L; i++) R.a[i] = 0;
    for (int i = 0; i < L; i++)
      for (int j = 0; i + j < L; j++) R.a[i + j] += a[i] * A.a[j];
    for (int i = 0; i < L - 1; i++) {
      R.a[i + 1] += R.a[i] / 10;
      R.a[i] %= 10;
    }
    R.a[L - 1] %= 10;
    return R;
  }
  void print() {
    int m = L - 1;
    while (a[m] == 0) m--;
    for (int i = m; i >= 0; i--) printf("%d", a[i]);
    printf("\n");
  }
};
char s[L];
int a[L];
Num P200;
Num P1;
void solve() {
  scanf("%s", s);
  Num ANS = Num(200);
  int len = strlen(s);
  for (int i = 0; i < M; i++) a[i] = 0;
  for (int i = 0; i < len; i++) a[M - 1 - i] = (int)(s[i] - '0');
  long long X = 0;
  for (int i = M - 1; i >= 0; i--) {
    X *= 10;
    X &= (1LL << M) - 1;
    X += a[i];
    X &= (1LL << M) - 1;
  }
  X = (1LL << M) - X;
  if (X % 10 == 0) X += 1LL << M;
  for (int i = 0; i < M - 12; i++) {
    a[i] = X % 10;
    X /= 10;
  }
  Num PER = Num(2);
  Num PERLEN = Num(1);
  Num CUR = P200;
  for (int k = 0; k < M; k++) {
    while (a[k] != CUR.a[k]) {
      ANS = ANS + PERLEN;
      CUR = CUR * PER;
    }
    Num NEWPERLEN = PERLEN;
    Num NEWPER = PER;
    Num NXT = CUR * PER;
    while (CUR.a[k] != NXT.a[k]) {
      NXT = NXT * PER;
      NEWPER = NEWPER * PER;
      NEWPERLEN = NEWPERLEN + PERLEN;
    }
    PER = NEWPER;
    PERLEN = NEWPERLEN;
  }
  ANS.print();
}
int main() {
  P1 = Num(2);
  P200 = Num(1);
  for (int i = 0; i < 200; i++) P200 = P200 * P1;
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}