Problems
Izabella and Olga are playing a new game alternating turns. In this game, they personify attraction inventors working for a theme park. The board is a matrix of square cells that illustrates the map of the theme park. Some cells were deemed apt to host a new attraction.
When an attraction is built, signs to advertise it are added automatically.
For example, suppose the left picture below represents a map, with yellow cells representing the
spots where attractions can be built. After an attraction is built on
In a turn, a player can choose to build an attraction in any available spot, and then the sign builders proceed automatically, possibly invalidating other spots as in the example. The goal of the game is to outlast the opponent: the player that, in her turn, does not have any available spot to build an attraction loses the game.
Izabella plays first. Assuming both players play optimally to win the game, can you count how many different plays on Izabella's first turn would result in her winning?
Input
The first line of the input gives the number of test cases, X if the cell in the .) if it is not.
Output
For each test case, output one line containing Case #,
where
Example
4
5 7
.......
...X.X.
...X.X.
..XX...
..X....
1 5
X.X.X
2 5
X.X.X
.X.X.
2 2
X.
.X
Case #1: 1
Case #2: 3
Case #3: 1
Case #4: 2