Easy

36.73%

Given a number n, count minimum steps to minimise it to 1 according to the following criteria:

- If n is divisible by 2 then we may reduce n to n/2.
- If n is divisible by 3 then you may reduce n to n/3.
- Decrement n by 1.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer N denoting the number n.

**Output:**

Output the minimum steps to minimise the number in a new line for each test case.

**Constraints:**

1<= T <=1000

1<= N <=10000

**Example:**

**Input:**

2

10

6

**Output:**

3

2