Three friends -- Alice, Bob, and Cynthia -- constantly find themselves with debts to settle among each other. That is the price of spending a lot of time together: a few restaurant visits, a couple of movies, and a round or two of drinks are enough to leave an unsettled balance. So when they meet as usual every Friday afternoon, they start the evening by clearing the previous week's debts.
Being mathematically minded, they prefer to settle up while moving as little money as possible -- that is, by exchanging as few bank notes and coins as they can. To their surprise, this is sometimes harder than it sounds.
Suppose Alice owes Bob 10 crowns and this is the friends' only outstanding debt. Alice has a single 50-crown note and nothing smaller, Bob has three 10-crown coins and ten 1-crown coins, and Cynthia has three 20-crown notes. The best way to clear the debt is for Alice to give her 50-crown note to Cynthia, Cynthia to give two 20-crown notes to Alice and one to Bob, and Bob to give one 10-crown coin to Cynthia -- a total of only five notes and coins changing hands. Compare that with the straightforward approach of Alice handing her 50-crown note to Bob and receiving Bob's three 10-crown coins and all ten of his 1-crown coins as change, for a total of fourteen notes and coins exchanged.
Given the debts among the three friends and exactly what money each of them is carrying, determine the minimum number of notes and coins that must change owner in order to settle every debt.
The first line contains a single positive integer $t$ ($1 \le t \le 50$), the number of test cases.
Each test case begins with a line containing three integers $ab$, $bc$, $ca$ (each at most $1000$). $ab$ is the amount Alice owes Bob, and is negative if instead Bob owes Alice. $bc$ is the amount Bob owes Cynthia, and is negative if instead Cynthia owes Bob. $ca$ is the amount Cynthia owes Alice, and is negative if instead Alice owes Cynthia.
Three lines follow, describing the money held by Alice, Bob, and Cynthia in that order. Each line contains six non-negative integers -- the number of 100-, 50-, 20-, 10-, 5-, and 1-crown notes and coins that person holds, in that order. Each person carries at most 30 coins (that is, for each person the number of 10-, 5-, and 1-crown pieces sums to at most $30$), and the total value of all the money the three friends hold together is always less than $1000$ crowns.
For each test case, output a single line containing the minimum number of notes and coins that must change owner to settle the balance. If settling the debts is not possible at all, output the string impossible instead.