beecrowd | 1147

Knight Scape

By Gerson Groth Brazil

Timelimit: 1

Your friend Peter is learning chess. But he's still amateur and doesn't have enough conviction to make secure movements of the knight piece. This way, Peter asked you to make a program that calculate, in one turn, the distinct possible movements that the knight can perform, without be on attack of any of the 8 existing pawns. The knight's movements and pawn's movements are according to the chess rules, that means the knight must move in L and the pawn must move one square to any direction, without going back. Look the following example.

In the picture, considering all 8 possible positions to move the Knight, two of them are under attack (6b and 3e). In the other squares, the knight can be moved without problem, escaping this way of the any pawn attack. In the 2b square a pawn already exists, but is also a valid moviment to the knight, because it can go to this position and "kill" the pawn.

So, as the given example, the secure (valid) movements are 6. You must remember that the black pawn can move from up to down int the table, from line 7 to line 1.


The input file consist in many test cases. Each test case consist in 9 input lines. The first line indicates the initial position of the knight. The following 8 lines describe the respectively pawn positions.

The last line of the input file contains only the number 0 (Zero).


For each test case your program must print an unique line, containig the descrition:

Caso de Teste #Y: X movimento(s).

Where Y represents the test case, X represents the among of possible secure movements to the knight without be on pawn attack.

Input Sample Output Sample


Caso de Teste #1: 6 movimento(s).