#include <bits/stdc++.h>
#define endl "\n"
#define INT long long int

using namespace std;

char infile[100], outfile[100];

int main() {
    ios::sync_with_stdio(false);
    INT T,a, b, n, t, i, I,c;
    cin >> T;
    for(I=11;I<=10+T;I++){
        sprintf(infile, ".%d.in", I);
        freopen(infile, "w", stdout);
        scanf("%lld",&a);
        printf("%lld\n", a);
        sprintf(outfile, ".%d.out", I);
        freopen(outfile, "w", stdout);
        b = 0;
        while(a%10==0){
            b++;
            a = a/10;
        }
        while(a%5==0){
            b++;
            b++;
            a=a/5;
        }
        if(a==1){
            printf("%lld\n",b);
        }else{
            printf("-1\n");
        }
    }
}
