AT_abc462_g [ABC462G] Completely Wrong

Description

There is a box containing $ N $ balls numbered $ 1 $ through $ N $ . Each ball is painted with a color represented as an integer, and ball $ i $ is painted with color $ C_i $ . Takahashi performed $ N $ operations. The $ k $ -th operation $ (1\le k\le N) $ is as follows: - Draw one ball uniformly at random from the box and discard it. If the drawn ball has color $ G_k $ , gain $ 1 $ point. Find the probability, modulo $ 998244353 $ , that the total score over $ N $ operations is $ 0 $ points. Definition of probability modulo $ 998244353 $ It can be proved that the sought probability is always a rational number. Furthermore, under the constraints of this problem, when the rational number is expressed as an irreducible fraction $ \frac{P}{Q} $ , it can be proved that $ Q {{}\not\equiv{}} 0 \pmod{998244353} $ . Thus, there exists a unique integer $ R $ satisfying $ R \times Q \equiv P \pmod{998244353} $ and $ 0 \leq R \lt 998244353 $ . Find this $ R $ .

Input Format

The input is given from Standard Input in the following format: > $ N $ > $ C_1 $ $ C_2 $ $ \ldots $ $ C_N $ > $ G_1 $ $ G_2 $ $ \ldots $ $ G_N $

Output Format

Output the sought probability modulo $ 998244353 $ .

Explanation/Hint

### Sample Explanation 1 For example, the operations may proceed as follows: - First operation: A ball with color $ 2 $ is drawn from the box. - Second operation: A ball with color $ 1 $ is drawn from the box. Gain $ 1 $ point. - Third operation: A ball with color $ 3 $ is drawn from the box. In this case, the total score is $ 1 $ point. The probability that Takahashi's total score is $ 0 $ is $ \displaystyle \frac13 $ . ### Sample Explanation 2 Takahashi's total score is always $ 1 $ point. ### Constraints - $ 1\le N\le 2\times 10^5 $ - $ 1\le C_i,G_k\le N $ - All input values are integers.