#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(ll i=0;i> T; while(T--){ ll A,B,C,x,y,z; cin >> A >> B >> C >> x >> y >> z; vector

v; v.push_back(P(A,x)); v.push_back(P(B,y)); v.push_back(P(C,z)); sort(v.begin(),v.end()); A=v[0].first; B=v[1].first; C=v[2].first; x=v[0].second; y=v[1].second; z=v[2].second; ll s; if(x-y-z>=0) s=(x-y-z)*A-x*A+y*B+z*C; else s=(x-y-z)*B-x*A+y*B+z*C; ll t; if(x+y-z>=0) t=(x+y-z)*B-x*A-y*B+z*C; else t=(x-y+z)*C-x*A-y*B+z*C; cout << min(s,t) << endl; } return 0; }