#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       long long int to = 0, thr = 0;       while (n % 2 == 0) {         to++;         n = n / 2;       }       while (n % 3 == 0) {         thr++;         n = n / 3;       }       if (n > 1) {         cout <<  -1 ;         cout <<   n ;       } else {         if (to > thr) {           cout <<  -1 ;           cout <<   n ;         } else {           cout << 2 * thr - to;           cout <<   n ;         }       }     }   }   