I often buy Coca-Cola from the vending machine at work. Usually I buy several cokes in once, since my working mates also likes. A Coke in the vending machine costs 8 Swedish crowns, and the machine accept with the values 1, 5 and 10. As soon as I press the Coke button (after has inserted sufficient amount of), I receive a Coke followed by the ex Change (if any). The exchange is always given into as few coins as possible (this are uniquely determined by the coin set used). This procedure are repeated until I ' ve bought all Cokes I want. Note This I can pick up the coin exchange and use those coins when buying further.
Now, what are the least number of coins I must insert, given the number of Cokes I want to buy and the number of coins I ha ve of each value? Please help me solve this problem while I create some harder problems for you. You may assume this machine won ' t run out of coins and that I always have enough I coins.
Input
The ' the ' the ' the ' the ' the ' number of test cases (at most contains). Each case is then given in a line by itself. A test case consists of four integers: C (the number of Cokes I want to Buy), n1, n 5( the number of coins of value 1, 5 and Respecti vely). The input limits are 1 <= C <=, 0 <= n1 <=, 0 <= n5 <= and 0 <= n <= .
Output
For each test case, output a line containing a single integer:the minimum number of coins needed to insert into the Vendi Ng Machine.
Sample input Output for sample input