rakesh loves to play number games. when He was surfing on google he found one of the game. The theme of the game is to find the shortest way that he can make the number equal to 1. He can only perform only three operations they are -1, /2, /3. As the level of game increased and he was facing difficulty to solve the large numbers, So he wanted solve this problem for him.

INPUT:
first line consists of T test cases.
Next T lines consists of a decimal number N.

OUTPUT
For every number return the shortest way to make it to 1.

0< T < 100
0<N<10^9

SAMPLE INPUT
2
12
35

SAMPLE OUTPUT
3
7
for _ in xrange(input()):
	n=input()
	ans=0
	while n>1:
		if n%3==0:
			n/=3
		elif n%2==0:
			n/=2
		else:
			n-=1
		ans+=1
	print ans