Description
There is a square grid with $N \times N$ cells. We denote the cell in the $i$-th row from the top and the $j$-th column from the left as $(i, j)$. Each cell $(i, j)$ has an integer $A_{i,j}$ written on it, satisfying $1 \le A_{i,j} \le (N - K)^2$. You are going to perform the following operations in order:
- Choose $K$ out of the $N$ rows and remove the cells in the chosen rows.
- Choose $K$ out of the $N$ columns and remove the cells in the chosen columns.
Depending on how the rows and columns are chosen, the integers written on the remaining $(N - K)^2$ cells may be pairwise distinct. Find the number of ways to choose the rows and columns to remove such that this condition is satisfied, modulo $998244353$.
Two ways of choosing are considered different if and only if there is at least one row or column that is chosen in one way and not chosen in the other.
Input
The input is given from Standard Input in the following format:
N K
A_{1,1} A_{1,2} ... A_{1,N}
:
A_{N,1} A_{N,2} ... A_{N,N}Constraints
- $1 \le K < N \le 1000$
- $1 \le K \le 5$
- $1 \le A_{i,j} \le (N - K)^2$ ($1 \le i \le N, 1 \le j \le N$)
- All input values are integers.
Output
Print the number of ways to choose the rows and columns satisfying the condition, modulo $998244353$.
Examples
input1
3 1 3 1 4 1 4 2 2 3 1
output1
6
input2
3 2 1 1 1 1 1 1 1 1 1
output2
9
input3
6 3 1 7 2 5 6 8 8 9 1 7 5 9 5 2 3 6 4 1 1 2 6 3 9 2 2 4 3 1 5 4 6 9 5 4 2 2
output3
10
Note
Sample 1 Explanation
In the following $6$ ways of choosing, the remaining $(N - K)^2$ cells contain the integers $1, 2, 3, 4$ once each, so they satisfy the condition:
- Remove the $1$-st row from the top and the $1$-st column from the left
- Remove the $1$-st row from the top and the $2$-nd column from the left
- Remove the $1$-st row from the top and the $3$-rd column from the left
- Remove the $2$-nd row from the top and the $3$-rd column from the left
- Remove the $3$-rd row from the top and the $2$-nd column from the left
- Remove the $3$-rd row from the top and the $3$-rd column from the left