AT_arc218_a [ARC218A] Many Sets
Description
You are given $ N $ sequences of positive integers, each of length $ M $ . The $ i $ -th sequence is $ A_i=(A_{i,1},A_{i,2},\dots,A_{i,M}) $ .
There are $ M^N $ ways to choose one element from each of these $ N $ sequences. Find the sum, modulo $ 998244353 $ , of "the number of distinct integers among the chosen elements" over all such ways.
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ M $ $ A_{1,1} $ $ A_{1,2} $ $ \dots $ $ A_{1,M} $ $ A_{2,1} $ $ A_{2,2} $ $ \dots $ $ A_{2,M} $ $ \vdots $ $ A_{N,1} $ $ A_{N,2} $ $ \dots $ $ A_{N,M} $
Output Format
Output the answer.
Explanation/Hint
### Sample Explanation 1
For example, if $ A_{1,1} $ and $ A_{2,1} $ are chosen, there are two distinct integers among the chosen elements: $ 1 $ and $ 2 $ .
The number of distinct integers is $ 1 $ only when $ A_{1,2} $ and $ A_{2,2} $ are chosen, and it is $ 2 $ in the other three cases, so the answer is $ 7 $ .
### Constraints
- $ 1 \le N,M \le 500 $
- $ 1 \le A_{i,j} \le NM $
- All input values are integers.