#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<assert.h>
#include<set>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<iostream>
#include<bitset>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define per(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
using namespace std;
typedef long long LL;
typedef double db;
const int N=3225;
int n,m,k;LL a,b,c;
LL f[N];
void Main(){
scanf("%d%d%d%lld%lld%lld",&n,&m,&k,&a,&b,&c);
assert(0<=n&&n<=1000);
assert(0<=m&&m<=1000);
assert(0<=k&&k<=1000);
assert(0<=a&&a<=1000000000);
assert(0<=b&&b<=1000000000);
assert(0<=c&&c<=1000000000);
rep(i,0,n+k+m+20)f[i]=(1ll<<60);
rep(i,0,n+k+m+20)rep(x,0,i/2)if((i-2*x)%3==0){
int y=(i-2*x)/3;
//枚举 i,x,计算 y
f[i]=min(f[i],a*1ll*x+b*1ll*y);
}
//计算 f
per(i,n+k+m+19,0)f[i]=min(f[i],f[i+1]);
LL ans=1ll<<60;
rep(i,0,k)ans=min(ans,i*1ll*c+f[n+k-i]+f[m+k-i]);
printf("%lld\n",ans);
}
int main(){
int t;scanf("%d",&t);
assert(1<=t&&t<=50);
while(t--)Main();
return 0;