{"problem":{"name":"Use Udon Coupon","description":{"content":"You are given positive integers $N, L, R$ and length-$N$ positive integer sequences $A = (A_{1}, A_{2}, \\dots, A_{N}), B = (B_{1}, B_{2}, \\dots, B_{N})$. Using a sequence $Q$ initialized as empty, a v","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc204_a"},"statements":[{"statement_type":"Markdown","content":"You are given positive integers $N, L, R$ and length-$N$ positive integer sequences $A = (A_{1}, A_{2}, \\dots, A_{N}), B = (B_{1}, B_{2}, \\dots, B_{N})$.\nUsing a sequence $Q$ initialized as empty, a variable $C$ initialized to $0$, and a variable $i$ initialized to $1$, perform the following operation $2N$ times.\n\n*   Choose one of the following actions $1, 2$ and perform it.\n    *   Action $1$ : Insert $i$ at the end of $Q$, replace $C$ with $\\max(0, C - A_{i})$. Then, increase $i$ by $1$. This action can only be performed when $i$ before the operation is at most $N$.\n    *   Action $2$ : Let $x$ be the first number in $Q$, and add $B_{x}$ to $C$. Then, remove the first element of $Q$. This action can only be performed when $Q$ before the operation is not empty.\n\nFind the number, modulo $998244353$, of ways to perform $2N$ operations such that the final value of $C$ is between $L$ and $R$, inclusive.\n\n## Constraints\n\n*   $1\\leq N\\leq 5000$\n*   $1\\leq L \\leq R \\leq \\sum B$\n*   $1\\leq A_{i}\\leq 5000$\n*   $1\\leq B_{i}\\leq 5000$\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $L$ $R$\n$A_{1}$ $A_{2}$ $\\dots$ $A_{N}$\n$B_{1}$ $B_{2}$ $\\dots$ $B_{N}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc204_a","tags":[],"sample_group":[["2 100 1000\n2001 167\n924 178","1\n\nFor example, you can perform four operations as follows.\n\n*   Perform action $1$. Then, $Q = (1), C = 0, i = 2$.\n*   Perform action $2$. Then, $Q = (), C = 924, i = 2$.\n*   Perform action $1$. Then, $Q = (2), C = 757, i = 3$.\n*   Perform action $2$. Then, $Q = (), C = 935, i = 3$.\n\nPerforming operations as above makes the final value of $C$ between $100$ and $1000$ (inclusive). This is the only such way to perform operations, so output $1$."],["3 10 10\n1 6 7\n9 2 4","0"],["15 167 924\n122 122 111 85 97 108 115 82 84 82 105 103 113 102 135\n116 122 110 106 71 85 70 94 86 110 73 97 101 86 73","9576277"]],"created_at":"2026-03-03 11:01:14"}}