include [HTML_REMOVED]
using namespace std;
int main() {
int a,b,c,d,e,f,t;
cin>>t;
while(t–){
cin>>a>>b>>c>>d>>e>>f;
int ans = 0;
if(e>f){
int x1 = min(a,d);
d -= x1;
ans += x1e;
int x2 = min(min(b,c),d);
ans += x2f;
}
else{
int x2 = min(min(b,c),d);
ans += x2f;
d -= x2;
int x1 = min(a,d);
ans += x1e;
}
cout<<ans<<endl;
}
return 0;
}