#include
using namespace std;
int main() {
int t, c1, c2, c3, c4, n, m, rickshaw[100], cab[100], rickshaw_cost = 0, cab_cost = 0, cost = 0;
/*
t -> no of testcases
c1 -> A ticket for one ride on some rickshaw or cab
c2 -> A ticket for an unlimited number of rides on some rickshaw or on some cab.
c3 -> A ticket for an unlimited number of rides on all rickshaws or all cabs.
c4 -> A ticket for an unlimited number of rides on all rickshaws and cabs.
n -> no of rickshaws
m -> no of cabs
*/
cout<<"Enter no of testcases: ";
cin>>t;
while (t >= 1) {
cout<<"Enter the costs: ";
cin>>c1>>c2>>c3>>c4;
cout<<"Enter no of rickshaws and cabs: ";
cin>>n>>m;
for (int i=0; i<n; i++) {
cout<<"Enter no of times Ramu uses rickshaw "<<i+1<<": ";
cin>>rickshaw[i];
}
for (int i=0; i<m; i++) {
cout<<"Enter no of times Ramu uses cab "<<i+1<<": ";
cin>>cab[i];
}
for (int i=0; i<n; i++) {
rickshaw_cost += min(c1*rickshaw[i], c2);
}
rickshaw_cost = min(rickshaw_cost, c3);
for (int i=0; i<m; i++) {
cab_cost += min(c1*cab[i], c2);
}
cab_cost = min(cab_cost, c3);
cost = min(rickshaw_cost+cab_cost, c4);
cout<<cost<<endl;
t -= 1;
}
return 0;
}