You are given a box full of mirrors. Box consists of grid of size
n×m. Each cell of the grid contains a mirror put in the shape of '
\' or '
/' (
45 degree to the horizontal or vertical line). But mirrors in some cells have been destroyed. You want to put new mirrors into these grids so that the following two conditions are satisfied:
-
If you put a light ray horizontally/vertically into the middle of any unit segment that is side of some border cell, the light will go out from the neighboring unit segment to the segment you put the ray in.
-
each unit segment of the grid of the mirror box can be penetrated by at least one light ray horizontally/vertically put into the box according to the rules of the previous paragraph
After you tried putting some mirrors, you find out that there are many ways of doing so. How many possible ways are there? The answer might be large, so please find the result modulo prime number
MOD.
Output
Output the answer modulo
MOD.
Note
The only way for sample 1 is shown on the left picture from the statement.
The only way for sample 2 is shown on the right picture from the statement.
For the third sample, there are
5 possibilities that are listed below:
1.
2.
3.
4.
5.
The answer is then module by
3 so the output should be
2.