Balanced Change

No attempts yetTime limit1sMemory limit128 MB

Problem

When a clerk gives a customer change, they normally hand over the fewest coins possible — a customer owed $2 in change usually receives one $2 coin rather than two $1 coins or four 50c coins. When the coins in the drawer are stocked unevenly, however, the fewest-coins strategy is not always best: if the drawer is overflowing with $1 coins, handing over two $1 coins can be better simply to draw that bucket down.

The cash drawer has five buckets, holding $2, $1, 50c, 20c and 10c coins. Define the imbalance of the drawer as follows. Let min be the smallest number of coins held in any one bucket. The imbalance is the sum, over all five buckets, of the square of how many coins that bucket holds above min. For example, if the drawer holds 2, 3, 4, 3 and 5 coins of $2, $1, 50c, 20c and 10c respectively, then min = 2 and the imbalance is (22)2+(32)2+(42)2+(32)2+(52)2=0+1+4+1+9=15(2-2)^2 + (3-2)^2 + (4-2)^2 + (3-2)^2 + (5-2)^2 = 0 + 1 + 4 + 1 + 9 = 15.

Given the coins in the drawer and an amount of change to hand out, choose which coins to give so that the imbalance of the coins remaining in the drawer is as small as possible. If several selections achieve the same minimum imbalance, pick the one that gives away the most $2 coins; if that is still tied, prefer the most $1 coins, then the most 50c coins, and so on.

Input

The input contains several change-giving problems, one per line. Each line has five integers followed by an amount of money. The five integers are the numbers of $2, $1, 50c, 20c and 10c coins currently in the drawer. The amount has the form $n.m, where the whole-dollar part n is always present (possibly zero) and the cents part m is always two digits; it is the change to be handed out.

The input ends with a line of five zeros followed by $0.00, which is not a problem to solve. Every amount of change to hand out is greater than zero and at most $5.

Output

For each problem, print one line beginning with Problem #k:, where k is the problem's position in the input, starting at 1. Follow it with the coins to give: for each denomination that is used, in the order $2, $1, 50c, 20c, 10c, write the count and the denomination (for example 2 50c). Separate several entries with commas, place and before the final entry, and end the line with coin(s). If it is impossible to give the exact change, print not possible after the Problem #k: label instead.