# SOLUTION

You go to a shop to buy masks in this pandemic.
Now, there are 3 different types of packets of mask

• A packet of 10 masks
• A packet of 5 masks
• A packet of 1 mask

You are given the costs of each packet. A packet of 10 masks costs Rs. XX, a packet of 5 masks costs Rs. YY and a packet of 1 mask costs Rs. ZZ.

You need to find the minimum sum of rupees you need to pay to buy a total of exactly NN masks from the shop.

NOTE: You can buy any number of each type of packet (can be 0).

• First line will contain TT, number of testcases. Then the testcases follow.
• Each testcase contains of a single line of input, four integers N,X,Y,ZN,X,Y,Z.

For each testcase, output in a single line minimum Rupees you need to pay to buy NN masks.

• 1T1051≤T≤105
• 1N,X,Y,Z1061≤N,X,Y,Z≤106

### Sample Input: Buy Masks solution codechef

2
17 10 10 3
19 30 10 1


### Sample Output:

26
19


### EXPLANATION:

Test case 1: He will buy 1 packet of 10 masks (cost = Rs 1010), 1 packet of 5 masks (cost = Rs. 1010) and 2 packets of 1 mask (cost = Rs. 66).
Total cost = 10 + 10 + 6 = Rs. 26