#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
long long n;
scanf("%lld",&n);
if(n%3==0)
{
printf("%lld\n",n*n*n/27ll);
continue;
}
if(n%4==0)
{
printf("%lld\n",n*n*n/32ll);
continue;
}
printf("-1\n");
}
return 0;
}