CF1176A.Divide it!

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Divide it!

You are given an integer nn.

You can perform any of the following operations with this number an arbitrary (possibly, zero) number of times:

  1. Replace nn with n2\frac{n}{2} if nn is divisible by 22;
  2. Replace nn with 2n3\frac{2n}{3} if nn is divisible by 33;
  3. Replace nn with 4n5\frac{4n}{5} if nn is divisible by 55.

For example, you can replace 3030 with 1515 using the first operation, with 2020 using the second operation or with 2424 using the third operation.

Your task is to find the minimum number of moves required to obtain 11 from nn or say that it is impossible to do it.

You have to answer qq independent queries.

Input

The first line of the input contains one integer qq (1q10001 \le q \le 1000) — the number of queries.

The next qq lines contain the queries. For each query you are given the integer number nn (1n10181 \le n \le 10^{18}).

Output

Print the answer for each query on a new line. If it is impossible to obtain 11 from nn, print -1. Otherwise, print the minimum number of moves required to do it.

Samples

7
1
10
25
30
14
27
1000000000000000000
0
4
6
6
-1
6
72

在线编程 IDE

建议全屏模式获得最佳体验