A football team consists of $$$n$$$ players (numbered $$$1$$$ through $$$n$$$) and a goalkeeper, and they are practicing passing.
The practice procedure is as follows:
Now the goalkeeper wants to know the expected total number of passes made by the players when he stops the ball.
The first line contains a positive integer $$$n$$$ ($$$1\le n \le 16$$$), denoting the number of players.
The next $$$n$$$ lines each contain $$$n$$$ integers $$$a_{i,j}$$$ ($$$0\le a_{i,j} \lt 998244353$$$). Here, after player $$$i$$$ gets the ball, the probability that they pass it to player $$$j$$$ is $$$p_{i,j} = \frac{a_{i,j}}{\sum_{k=1}^n a_{i,k}}$$$.It is guaranteed that for every $$$1\le i\le n$$$, we have $$$\left(\sum_{k=1}^n a_{i,k}\right) \not\equiv 0 \pmod{998244353}$$$.
If the expectation converges, output the answer modulo $$$998244353$$$; otherwise, output infinity.
It can be proven that if the expectation converges, then it can always be written as a rational number $$$\frac{p}{q}$$$, where $$$p,q$$$ are integers, $$$p\ge 0$$$, and $$$q\ge 1$$$. You should output the value of $$$p\cdot q^{-1}\bmod 998244353$$$, where $$$q^{-1}$$$ denotes the modular inverse of $$$q$$$ modulo $$$998244353$$$, which satisfies $$$q \cdot q^{-1} \equiv 1 \pmod {998244353}$$$.
51 0 0 0 02 1 0 0 03 0 1 0 04 0 0 1 05 0 0 0 1
infinity
50 1 0 0 00 0 1 0 00 0 0 1 00 0 0 0 11 0 0 0 0
10
65 6 499122175 10 10 9982443527 998244351 7 4 499122176 34 10 2 9 8 96 6 6 3 10 10998244351 3 1 499122175 10 93 7 6 499122176 499122176 3
53368493
18
2
| Название |
|---|


