Metro Manila currently has five circumferential roads arranged in concentric semicircles, with a sixth to be constructed linking the north and the south. From the center (Manila), there are ten radial roads that connect the inner and outer areas of Metro Manila.

Figure 1 Ideal road network of Metro Manila
In this problem, you are to find the shortest distance from point A to point B. Each point is determined by the intersection of a circumferential and a radial road, denoted as (\textbf{C\#}, \textbf{R\#}), and the center is represented as (\textbf{C0}, \textbf{R0}).
For calculation purposes, the distance for each segment along a radial road is equal to unit, while each arc along a circumferential road has length equal to the circumferential road's number. For example, the distance from (\textbf{C1}, \textbf{R3}) to (\textbf{C2}, \textbf{R3}) is unit, and the distance from (\textbf{C3}, \textbf{R1}) to (\textbf{C3}, \textbf{R2}) is units. The shortest distance from (\textbf{C1}, \textbf{R2}) to (\textbf{C5}, \textbf{R1}) is units (see the darkened path). It is assumed that is passable for this problem.
However, with the new number coding scheme, vehicles are not allowed to use a radial road if its number matches the last digit of the vehicle's plate number. For instance, a vehicle with the plate number ABC-123 cannot use . Furthermore, circumferential roads (except for ) also have restrictions: plate numbers ending in and are not allowed on , and are not allowed on , and on , and on , and and on . Thus, the shortest path from (\textbf{C1}, \textbf{R2}) to (\textbf{C5}, \textbf{R1}) is units for a vehicle with plate number ABC-123, but units for a vehicle with plate number CBA-321. Note that there may be instances in which a vehicle cannot reach the destination at all.
The input consists of multiple test cases. For simplicity, each test case consists of single-digit numbers separated by whitespace. The first two numbers represent the starting point, the next two numbers represent the destination point, and the last number is the last digit of the vehicle's plate number. There are no blank lines between test cases, and the final test case is followed by a line containing a single zero.
For each test case, print the case number (starting from ) followed by the length of the shortest required distance. Print not possible if the destination cannot be reached.
Example 1