Cheema was teaching his Bot to understand human way of talking. There is one serious problem with that humans mean something else and say something else. Sometimes the sentence is totally meaningless. For example sometimes if one is going to market to buy some goods and ask his friend "how many items to buy ??" . we generally reply "saat aath le aana" ... which is totally meaningless for a bot to understand as he will get confused how many exactly to buy.
Now Cheema got an idea, he defined this to bot as it has to buy that amount in which he will have to spend less amount of money.if in both the cases money spent is equal then he will prefer the way in which more items are there. for example one asks bot to bring "saat aath" coke bottles . and in market 7 coke bottles cost 560 rupees and if we buy 8 pack it cost 540 rupees . then bot will buy 8 instead of 7.
Now bot was ordered by Cheema to buy "n m" apples form market. Bot went to market . Market was strange. He went to the Apples section and enquired about the prices. The salesman gave him a card in which he found that the prices of apples were not per kg. The apples were packed into different type of packets packets. x type packet contains ‘x’ apples, x > 0 and ‘x’ is an integer. An x type packet would be valued at ‘y’ rupees. So, the card contained a table with an entry ‘y’ denoting the price of an ‘x’ type packet. If ‘y’ is -1 it means that the corresponding packet is not available. Now as apples are available only in packets . Bot can buy a x type packet multiple times . He can also buy more than one type of packets . Bot decided to check possible ways to buy m and n apples . Bot has to spend minimum amount of money . Help him deciding which combination to buy and how much money will he spend .
INPUT The first line of input will contain the number of test cases, t.
Each test case will contain two lines.
First line contains two integers n m .(he was told to buy "n m" apples)
Second line will contain k (where k is max of n and m) space separated integers in which the ith integer specifies the price of a ‘i’ apple packet.
0 < t <= 1000
0 < n <= 1000
0 < m <= 1000
0 < price <= 1000
OUTPUT The output for each test case should be a single line containing the minimum amount of money bot has to spend to buy apples. Print -1 if it is not possible to buy n and m apples.
1 we have no way to buy 3 and 5 apples as only packet of 4 is available.
2 buying 4 will cost 4 rupees and buying 5 will cost 5 rupees. so bot will buy 4 apples by spending 4 rupees
3 whether bot buys 3 or 4 he will have to spend 4 rupees so he will buy 4 apples by spending 4 rupees
4 same as coke bottle problem 7 cost 560 8 costs 540 he will go for 8 spending 540 rupees
5 he will buy 2 as less money is spent so ans is 20