Given a grid with rows and
columns, some cells in the grid are blocked, while other cells are empty. Bob has an infinite number of dominos and he wants to place his dominos into the grid. Each domino will occupy
or
cells, where the two cells must be both empty and be adjacent by sharing a common edge. Bob can place any number of dominos (maybe just 0), but dominos placed in the grid cannot overlap.
Bob will also place a flag in the grid, which takes one empty cell. The flag will be treated as a blocked cell. Bob hasn't determined which cell he wants to put his flag. He wants you to write a program to find out the number of different ways to place dominos, if he puts his flag in each cell . Since the answer is very huge, output the answer
. If the cell where Bob wants to place flag is blocked, output
.
Input Specification
The first line of input contains two integers and
, (
), the number of rows and columns of the grid.
Each of the following lines contains
integers,
(
is either
or
), indicating that the cell
is empty if
, or blocked if
.
Output Specification
Output lines, and each line contains
integers
, the number of ways to place dominos if Bob places his flag in the cell
. Since the answer is very huge, output the answer
. If the cell where Bob wants to place flag is blocked, output
.
Constraints
Subtask | Points | Additional constraints |
---|---|---|
No additional constraints. |
Sample Input
2 4
0 0 0 0
0 0 0 1
Sample Output
14 13 10 22
15 11 17 0
Explanation for Sample
If Bob places his flag at the cells , the gird is shown in the following picture.
There are different ways to place dominos, shown as following picture.
Comments