I have a palette with $n$ rows and $m$ columns, forming $n \times m$ cells, and each cell must contain a flower. There are $3$ colors of flowers available, denoted by $0, 1, 2$.
Flowers observe their neighbors and want to change their appearance to match other flowers. At any given moment, if a flower of color $c$ has at least one neighbor (up, down, left, or right) with color $c-1 \pmod 3$, then this flower will change to color $c-1 \pmod 3$ in the next moment; otherwise, its color remains $c$ in the next moment.
For an initial configuration of flowers on the palette, we call the configuration beautiful if, after a finite number of moments, all flowers become the same color.
It is not difficult to see that for a beautiful configuration, every flower has an earliest moment after which it no longer changes color. We call this moment the stabilization time of the flower. We start counting from time $0$, so if a flower never changes color, its stabilization time is $0$.
Now, I have already placed flowers in some cells of the palette, while some cells are empty. I want to know how many ways there are to place flowers in the remaining cells such that the configuration is beautiful, and what the sum of the stabilization times of the flower in the cell at row $1$, column $1$ is for all such beautiful configurations.
You only need to output these two results modulo $998244353$.
Input
The input is read from standard input.
The first line contains two positive integers $n$ and $m$ ($2 \le n \le 5$, $2 \le m \le 50$).
The next $n$ lines each contain $m$ integers. The $j$-th integer in the $i$-th line, $a_{i,j} \in \{0, 1, 2, 3\}$, represents the state of the corresponding cell. $a_{i,j} \in \{0, 1, 2\}$ indicates that there is a flower of that color, and $a_{i,j} = 3$ indicates that the cell is empty.
Output
Output to standard output.
Output a single line containing two integers: the number of beautiful configurations and the sum of the stabilization times of the flower in the top-left cell, both modulo $998244353$.
Examples
Input 1
2 2
1 0
3 2
Output 1
1 2
Note 1
The configuration is beautiful only when the empty cell is filled with a flower of color $0$. After two moments, all flowers become color $2$. At this point, the flower in the top-left cell becomes color $2$ and does not change further, so its stabilization time is $2$.
Input 2
5 5
3 3 3 3 2
2 3 3 3 1
1 3 3 3 3
3 3 3 3 3
3 3 3 3 3
Output 2
50830224 170059345