#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
#define eps 1e-6
double f(double x,double y)
{
return 6.0*pow(x,7.0)+8.0*pow(x,6.0)+7.0*pow(x,3.0)+5.0*pow(x,2.0)-y*x;
}
int main()
{
int t,tt;
double sum,mid,tmid,l,r,y;
freopen("in.txt","r",stdin);
scanf("%d",&t);
for(tt=1;tt<=t;tt++)
{
scanf("%lf",&y);
l=0;r=100;
while((r-l)>eps)
{
mid=(l+r)/2;
tmid=(mid+r)/2;
if(f(mid,y)<f(tmid,y))
r=tmid;
else
l=mid;
}
printf("%.4lf\n",f(mid,y));
}
return 0;
}