#include using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef pair pll; typedef long double D; //typedef complex P; #define F first #define S second const ll MOD=1000000007; //const ll MOD=998244353; templateistream & operator >> (istream &i,pair &A){i>>A.F>>A.S; return i;} templateistream & operator >> (istream &i,vector &A){for(auto &I:A){i>>I;} return i;} templateostream & operator << (ostream &o,const pair &A){o<ostream & operator << (ostream &o,const vector &A){int i=A.size(); for(auto &I:A){o<0 && bd>0 && cd>0){ret=min(ret,(A-ad)*X+(B-bd)*Y+(C-cd)*Z);} cd=C; ad=min(A,cd-1); bd=min(B,ad-1); if(ad>0 && bd>0 && cd>0){ret=min(ret,(A-ad)*X+(B-bd)*Y+(C-cd)*Z);} return ret; } ll solve2(ll A,ll B,ll C,ll X,ll Y,ll Z){ ll ret=min(solve1(A,B,C,X,Y,Z),solve1(C,B,A,Z,Y,X)); return ret==MX?-1LL:ret; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll T; cin>>T; for(int i=0;i>a>>b>>c>>x>>y>>z; cout<