Solve the programming task below in a Python markdown code block.
Darshit is planning to celebrate the birthday of his friend, Diksha. There are two types of gifts that Diksha wants from Darshit: one is black and the other is white. To make her happy, Darshit has to buy B number of black gifts and W number of white gifts.

The cost of each black gift is X units.

The cost of every white gift is Y units.

The cost of converting each black gift into white gift or vice versa is Z units.

Help Darshit by deducing the minimum amount he needs to spend on Diksha's gifts.

INPUT

The first line will contain an integer T which will be the number of test cases.
There will be T pairs of lines. The first line of each test case will contain the values of integers B and W. Another line of each test case will contain the values of integers X, Y, and Z.

OUTPUT

T lines, each containing an integer: the minimum amount of units Darshit needs to spend on gifts.

Constraints

1≤T≤10

0≤X,Y,Z,B,W≤109

SAMPLE INPUT
5
10 10
1 1 1
5 9
2 3 4
3 6
9 1 1
7 7
4 2 1
3 3
1 9 2

SAMPLE OUTPUT
20
37
12
35
12

Explanation

SAMPLE CASE 1:

There is no benefit to converting the white gifts into black or the black gifts into white, so Darshit will have to buy each gift for 1 unit. So cost of buying all gifts will be: 10∗1+10∗1=20. 

SAMPLE CASE 2:

Again, we can't decrease the cost of black or white gifts by converting colors. We will buy gifts at their original price. So cost of buying all gifts will be: 5∗2+9∗3=10+27=37. 

SAMPLE CASE 3:

We will buy white gifts at their original price, 1. For black gifts, we will first buy white one and color them to black, so that their cost will be reduced to 1+1=2. So cost of buying all gifts will be: 3∗2+6∗1=12.

SAMPLE CASE 4:

Similarly, we will buy white gifts at their original price, 2. For black gifts, we will first buy white one and color them to black, so that their cost will be reduced to 2+1=3. So cost of buying all gifts will be: 7∗3+7∗2=35.

SAMPLE CASE 5:

We will buy black gifts at their original price, 1. For white gifts, we will first black gifts worth 1 unit and color them to white with another 2 units, so cost for white gifts is reduced to 3 units. So cost of buying all gifts will be: 3∗1+3∗3=3+9=12.