P4978 God of Gambling: Duel

Background

**God of Gambling $\mathcal{CYJian}$ is back!**

Description

**$\mathcal{tomoo}$** decides to duel with **$\mathcal{CYJian}$**! It is known that **$\mathcal{tomoo}$** has $\mathcal{N}$ playing cards, and each card has an $\mathcal{RP}$ value $\mathcal{A_i}$. **$\mathcal{CYJian}$** has $\mathcal{M}$ playing cards, and each card has an $\mathcal{RP}$ value $\mathcal{B_i}$. **$\mathcal{CYJian}$** and **$\mathcal{tomoo}$** will each choose an arbitrary **contiguous interval** of cards from their own decks to duel. Whoever has the larger sum of $\mathcal{RP}$ values within their chosen interval wins. Please help compute the probability that **$\mathcal{tomoo}$** wins.

Input Format

- The first line contains two positive integers $\mathcal{N,M}$. - The second line contains $N$ positive integers $\mathcal{A_i}$. - The third line contains $M$ positive integers $\mathcal{B_i}$.

Output Format

Output one number representing the probability that **$\mathcal{tomoo}$** wins. If the answer can be written in the form $\frac{P}{Q}$, then output $\frac{P}{Q}\%998244353$ (if you do not understand, see [P3811](https://www.luogu.org/problemnew/show/P3811)).

Explanation/Hint

### Sample Explanation - Sample $3$: No matter how you choose, the result is always a tie on average, so the win rate is $0$. - Sample $5$: There are $9$ possible ways in total, and **tomoo** wins $3$ times, so the win rate is $1/3$. ### Constraints - For $20\%$ of the testdata, $0