#include<iostream>
#include<cmath>
using namespace std;
int main(){
int num;
cin>>num;
for(int i=0;i<num;i++){
long int x;
cin>>x;
int count = 0;
while(x!=1){
if(x%6==0){
x = x/6;
}else{
if(x%3!=0){
break;
}else{
x = x*2;
}
}
count++;
}
if(x==1){
cout<<count<<endl;
}else{
cout<<"-1"<<endl;
}
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-62107.html