a=input()
for i in range(a):
    p,s=map(int,raw_input().strip().split())
    p,s=[int(p),int(s)]
    p=p/4.0
    s=s/2.0
    l1=(2*p+(4*p*p-12*s)**0.5)/6.0
    l2=(2*p-(4*p*p-12*s)**0.5)/6.0
    if l1<p/3.0 and l1>0:
        l=l1
    elif l2<(p/3.0) and l2>0:
        l=l2
    v=s*l-(l*l*p) +(l*l*l)
    print str(round(v,2))