Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
G. Power Substring

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given *n* positive integers *a*_{1}, *a*_{2}, ..., *a*_{n}.

For every *a*_{i} you need to find a positive integer *k*_{i} such that the decimal notation of 2^{ki} contains the decimal notation of *a*_{i} as a substring among its last *min*(100, *length*(2^{ki})) digits. Here *length*(*m*) is the length of the decimal notation of *m*.

Note that you don't have to minimize *k*_{i}. 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 *a*_{i}.

Each of the next *n* lines contains a positive integer *a*_{i} (1 ≤ *a*_{i} < 10^{11}).

Output

Print *n* lines. The *i*-th of them should contain a positive integer *k*_{i} such that the last *min*(100, *length*(2^{ki})) digits of 2^{ki} contain the decimal notation of *a*_{i} as a substring. Integers *k*_{i} must satisfy 1 ≤ *k*_{i} ≤ 10^{50}.

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

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jan/17/2021 19:16:09 (h3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|