#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

## Problem Description

Gug is having fun with numbers! He starts off with an original number *X*, and can choose between the following operations:

- If
*X*is a multiple of 2, divide*X*by 2. - If
*X*is a multiple of 3, divide it by 3. - Subtract 1 from
*X*.

Gug repeats this until he is happy, which is when *X* becomes 0. Given a list of *N* integers that Gug starts with, determine for each integer *A _{i}*, the minimum operations it takes for Gug to be happy.

## Input

The first line of input will contain a single integer, *N*.

The second line of input will contain *N* integers, representing the array *A _{i}*.

## Output

The output should contain *N* lines with one integer each, with the integer on the *i*th line representing the number of operations it takes for Gug to be happy if he starts with *X* = *A _{i}*.

## Limits

Subtask 1 (30%): N = 1, 0 ≤ A_{i} ≤ 1000000..

Subtask 2 (31%): 1 ≤ N ≤ 10^{5}, 0 ≤ A_{i} ≤ 1000000.

Subtask 3 (39%): 1 ≤ N ≤ 10^{5}, 0 ≤ A_{i} ≤ 30000000.

Subtask 4 (0%): Sample Testcases.

## Sample Input 1

5 1 5 3 10 9

## Sample Output 1

1 4 2 4 3

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 30 | 20 | 1s | 256MB | Minimum |

2 | 31 | 41 | 1s | 256MB | Minimum |

3 | 39 | 61 | 1s | 256MB | Minimum |

4 | 0 | 1 | 1s | 256MB | Minimum |

### Judge Compile Command

g++-7 ans.cpp -o numberfun -Wall -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512