{"raw_statement":[{"iden":"problem statement","content":"Given is a sequence of $A+B$ integers $(X_1,X_2,\\cdots,X_{A+B})$, which contains exactly $A$ ones and exactly $B$ twos.\nSnuke has a set $s$, which is initially empty. He is going to do $A+B$ operations. The $i$\\-th operation is as follows.\n\n*   If $X_i=1$: Choose an integer $v$ such that $1 \\leq v \\leq A$ and add it to $s$. Here, $v$ must not be an integer that was chosen in a previous operation.\n    \n*   If $X_i=2$: Delete from $s$ the element with the largest value. The input guarantees that $s$ is not empty just before this operation.\n    \n\nHow many sets are there that can be the final state of $s$? Find the count modulo $998244353$."},{"iden":"constraints","content":"*   $1 \\leq A \\leq 5000$\n*   $0 \\leq B \\leq A-1$\n*   $1 \\leq X_i \\leq 2$\n*   $X_i=1$ for exactly $A$ indices $i$.\n*   $X_i=2$ for exactly $B$ indices $i$.\n*   $s$ will not be empty just before an operation with $X_i=2$.\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$A$ $B$\n$X_1$ $X_2$ $\\cdots$ $X_{A+B}$"},{"iden":"sample input 1","content":"3 1\n1 1 2 1"},{"iden":"sample output 1","content":"2\n\nThere are two possible final states of $s$: $s={1,2},{1,3}$.\nFor example, the following sequence of operations results in $s={1,3}$.\n\n*   $i=1$: Add $2$ to $s$.\n*   $i=2$: Add $1$ to $s$.\n*   $i=3$: Delete $2$ from $s$.\n*   $i=4$: Add $3$ to $s$."},{"iden":"sample input 2","content":"20 6\n1 1 1 1 1 2 1 1 1 2 1 2 1 2 1 2 1 1 1 1 2 1 1 1 1 1"},{"iden":"sample output 2","content":"5507"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}