#D. Divide it!

    远端评测题 1000ms 256MiB

Divide it!

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

You are given an integer $n$.

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

  1. Replace $n$ with $\frac{n}{2}$ if $n$ is divisible by $2$;
  2. Replace $n$ with $\frac{2n}{3}$ if $n$ is divisible by $3$;
  3. Replace $n$ with $\frac{4n}{5}$ if $n$ is divisible by $5$.

For example, you can replace $30$ with $15$ using the first operation, with $20$ using the second operation or with $24$ using the third operation.

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

You have to answer $q$ independent queries.

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

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

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

Input

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

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

Output

Print the answer for each query on a new line. If it is impossible to obtain $1$ from $n$, 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

Language6月月赛

未参加
状态
已结束
规则
IOI
题目
5
开始于
2023-6-10 10:00
结束于
2023-6-20 10:00
持续时间
240 小时
主持人
参赛人数
4