You are a rich person, and you think your wallet is too heavy and full now. So you want to give me some money by buying a lovely pusheen sticker which costs $p$ dollars from me. To make your wallet lighter, you decide to pay exactly $p$ dollars by as many coins and/or banknotes as possible.

For example, if $p = 17$ and you have two $\$10$ coins, four $\$5$ coins, and eight $\$1$ coins, you will pay it by two $\$5$ coins and seven $\$1$ coins. But this task is incredibly hard since you are too rich and the sticker is too expensive and pusheen is too lovely, please write a program to calculate the best solution.

For example, if $p = 17$ and you have two $\$10$ coins, four $\$5$ coins, and eight $\$1$ coins, you will pay it by two $\$5$ coins and seven $\$1$ coins. But this task is incredibly hard since you are too rich and the sticker is too expensive and pusheen is too lovely, please write a program to calculate the best solution.

The first line contains an integer $T$ indicating the total number of test cases. Each test case is a line with 11 integers $p, c_1, c_5, c_{10}, c_{20}, c_{50}, c_{100}, c_{200}, c_{500}, c_{1000}, c_{2000}$, specifying the price of the pusheen sticker, and the number of coins and banknotes in each denomination. The number $c_i$ means how many coins/banknotes in denominations of $i$ dollars in your wallet.

$1 \le T \le 20000$

$0 \le p \le 10^9$

$0 \le c_i \le 100000$

$1 \le T \le 20000$

$0 \le p \le 10^9$

$0 \le c_i \le 100000$

提交代码