TORONTO KIDS COMPUTER CLUB | Aurora Saturday 14:30 Python Practice 22.08.13.
20972

# Aurora Saturday 14:30 Python Practice 22.08.13.

## 18 Aug Aurora Saturday 14:30 Python Practice 22.08.13.

Question:

Jack save money by using piggy bank, he has many coins valued 1 cent, 5 cents, 10 cents, 50 cents and 1 dollar(100 cents) in the piggy bank.
Now Jack has a book to buy, it costs P cents. He wonders how many coins at least,and how many coins at most he can use to buy this nice book. Jack is a bit strange, he doesn’t like to get the change, that is, he will give the bookseller exactly P cents.

Input
T(T<=100) in the first line, indicating the case number.
T lines with 6 integers each:
P a1 a5 a10 a50 a100
ai means number of i-cents coin.
All integers are smaller than 1000000.

Output
Two integers A,B for each case, A is the fewest number of coins to buy the book exactly, and B is the largest number to buy exactly. If Jack can’t buy the book with no change, output “-1 -1”.

`Sample Input333 6 6 6 6 610 10 10 10 10 1011 0 1 20 20 20Sample Output6 91 10-1 -1`