Little Y likes to play the Meow Meow memory matching game.
A simplified version of the rules is as follows: there are $2n$ cards, each with a pattern on the front, and all backs are identical solid black, making them indistinguishable. There are $n$ types of patterns, with exactly $2$ cards for each pattern.
Initially, Little Y asks Little Z to help shuffle the cards randomly and arrange them face down in a row (i.e., every possible permutation of front patterns is equally likely), and the failure count is set to $0$. Each time, Little Y can sequentially choose two cards to flip over. If the patterns on these two cards are the same, they are removed, and Little Y sets them aside and ignores them; otherwise, he must immediately flip them back over and increment the failure count by one. The game ends when all cards are removed.
Little Y assumes his memory is perfect; if he flips a card and flips it back, he can always remember the pattern on it. He calls such cards "known," and others "unknown." He designed a strategy and repeats the following operations until the game ends:
- First, randomly flip an unknown card with equal probability. Let its pattern be $x$. If the other card with pattern $x$ is known, then flip that other card and remove both.
- Otherwise, randomly flip another unknown card with equal probability. Let its pattern be $y$. If $x=y$, remove both.
- Otherwise, this turn is a failure. Then, if the other card with pattern $y$ is known, proceed to flip the two cards with pattern $y$ and remove them.
Below is an example for $n=4$, where cards with a pattern on a black background are known cards that are face down.

Little Y found that this strategy is optimal, but he also wants to calculate the exact expected number of failures. He handed the problem to Little L, who not only solved it but also strengthened it: now, suppose Little Y has used some means to know the patterns of $m (m \le n)$ cards, and the patterns of these $m$ cards are all distinct. Then, all cards are face down, and the game is played using the above strategy to remove all cards. Let the expected number of failures be $E(n-m, m)$. Given two sequences $p_{0 \sim n-1}$ and $q_{0 \sim m-1}$, you need to calculate the following value modulo $998244353$:
$$\sum_{i=0}^{n-1}\sum_{j=0}^{m-1}\binom{2i+j}{i}p_iq_jE(i,j)$$
Input
The first line contains two integers $n, m$.
The second line contains $n$ space-separated integers $p_0, \dots, p_{n-1}$.
The third line contains $m$ space-separated integers $q_0, \dots, q_{m-1}$.
Output
A single integer representing the answer.
Examples
Input 1
3 2 0 1 2 3 4
Output 1
332748215
Note 1
Clearly, $E(1,0)=0$.
Consider $E(1,1)$. The first card flipped has a $2/3$ probability of having a pattern different from the known card, and the second card flipped has a $1/2$ probability of having a pattern different from the first card, resulting in one failure. No other failures are possible, so $E(1,1)=1/3$.
Consider $E(2,0)$. The second card flipped has a $2/3$ probability of having a pattern different from the first card, resulting in one failure. No other failures are possible, so $E(2,0)=2/3$.
It is easy to show by case analysis that $E(2,1)=13/15$.
In summary, the answer is:
$$\begin{align} &\; \binom{2}{1}\times1\times3\times0+\binom{3}{1}\times1\times4\times\frac13+\binom{4}{2}\times2\times3\times\frac23+\binom{5}{2}\times2\times4\times\frac{13}{15}\\ &=0+4+24+\frac{208}{3}\\ &\equiv332748215\pmod{998244353}\end{align}$$
Input 2
7 1 636562059 589284011 767928733 906523440 647212240 921212094 502480118 1
Output 2
114514
Note 2
$$ E(3,0)=4/3,E(4,0)=202/105 $$
Examples 3 & 4
See the provided files.
Constraints
| Subtask | $n \le$ | $m \le$ | Special Property | Score |
|---|---|---|---|---|
| $1$ | $10$ | $1$ | No | $5$ |
| $2$ | $17$ | $1$ | No | $5$ |
| $3$ | $2000$ | $2000$ | No | $10$ |
| $4$ | $5\times 10^4$ | $5\times 10^4$ | Yes | $30$ |
| $5$ | $2.5\times 10^5$ | $1$ | No | $10$ |
| $6$ | $10^5$ | $10^5$ | No | $30$ |
| $7$ | $2.5\times 10^5$ | $2.5\times 10^5$ | No | $10$ |
Special property: The product of the number of non-zero terms in $p$ and the number of non-zero terms in $q$ is at most $2500$.
For all data, $1 \le n, m \le 2.5\times 10^5, 0 \le p_i, q_i < 998244353$.