import sys sys.setrecursionlimit(10**7) def ii(): return int(input()) def mi(d=0): return map(lambda x:int(x)-d,input().split()) INF = float("inf") MOD = 998244353 def answer(s): print(s) exit() def cross(xy): x,y = xy return (x+1,y),(x-1,y),(x,y+1),(x,y-1) ################################################ t = ii() for _ in range(t): a,b,c,x,y,z = mi() ax,by,cz = sorted([(a,x),(b,y),(c,z)]) a,x = ax b,y = by c,z = cz aa = (b-a)*y + (c-a)*z bb = (b-a)*x + (c-b)*z cc = (c-a)*x + (c-b)*y print(min(aa,bb,cc))