This page is still under construction.

Parts of this page are still being built. What you see may change.

Harsh Comments

Time limit1sMemory limit1024 MB

Summary
Comments are deleted one at a time with probability proportional to downvotes; find the expected number of deletions until all of the first N comments are gone.
Level

Medium7 of 10

Topics
Probability, Combinatorics, Math, Dynamic programming
Solved
No attempts yet

Problem

A blog has N+MN+M harsh comments. You wrote NN of them, and the ii-th of your comments has AiA_i downvotes. The ii-th of the other MM comments has BiB_i downvotes.

Mike will delete the comments one by one by repeating the following operation:

  • Choose a comment at random and delete it. More precisely, let x1,x2,…,xkx_1,x_2,\ldots,x_k be the downvote counts of the remaining comments. He chooses the ii-th of them with probability xi/(∑1≤j≤kxj)x_i/\left(\sum_{1\leq j \leq k}x_j \right) and deletes it.

The choices in the operations are independent.

Find the expected number of operations Mike performs until he has deleted all of your comments. The answer is a rational number, so print it modulo 998244353998244353 as usual. It can be proved that this representation is always possible under the constraints of this problem.

Input

The first line contains the integers NN and MM (1≤N,M≤1001 \leq N,M \leq 100).

The second line contains the integers A1,A2,…,ANA_1,A_2,\ldots,A_N (1≤Ai≤1001 \leq A_i \leq 100).

The third line contains the integers B1,B2,…,BMB_1,B_2,\ldots,B_M (1≤Bi1 \leq B_i, ∑1≤i≤NAi+∑1≤i≤MBi<998244353\sum_{1 \leq i \leq N} A_i + \sum_{1 \leq i \leq M} B_i < 998244353).

Output

Print the answer.

Examples3

  1. Example 1

    Input
    1 2
    1
    1 1
    
    Expected output
    2
    
  2. Example 2

    Input
    1 1
    2
    1
    
    Expected output
    332748119
    
  3. Example 3

    Input
    3 3
    2 3 5
    7 11 900000000
    
    Expected output
    636512475