There is a village represented by an grid. Each cell is either a house or an empty lot.
The mayor wants to plant trees on empty lots. For a house, its neighboring cells are the at most cells that share an edge or a corner with it.
After planting trees, the following conditions must hold.
Planting a tree is expensive. Find the minimum number of trees that must be planted to satisfy the conditions.
The input is given from Standard Input in the following format:
For each test case, print the minimum number of trees that must be planted. If it is impossible to satisfy the conditions, print -1.
In the second test case, planting one tree in the middle cell of the second row places that tree next to both houses, so the total becomes .
In the third test case there are no houses, so the total remains regardless of where trees are planted.
Each case is given in the following format:
If the -th character of is #, the cell in row and column is a house. If it is ., the cell is an empty lot.
# and .. | 2 |
| 70 |
No additional constraints. |