{"problem":{"name":"#(subset sum = K) with Add and Erase","description":{"content":"We have a box, which is initially empty.   Let us perform a total of $Q$ operations of the following two types in the order they are given in the input. \\+ $x$ Type $1$: Put into the box a ball with","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc321_f"},"statements":[{"statement_type":"Markdown","content":"We have a box, which is initially empty.  \nLet us perform a total of $Q$ operations of the following two types in the order they are given in the input.\n\n\\+ $x$\n\nType $1$: Put into the box a ball with the integer $x$ written on it.\n\n\\- $x$\n\nType $2$: Remove from the box a ball with the integer $x$ written on it.  \n**It is guaranteed that the box contains a ball with the integer $x$ written on it before the operation.**\n  \n\nFor the box after each operation, solve the following problem.\n\n> Find the number, modulo $998244353$, to pick up some number of balls from the box so that the integers written on them sum to $K$.  \n> All balls in the box are distinguishable.\n\n## Constraints\n\n*   All input values are integers.\n*   $1 \\le Q \\le 5000$\n*   $1 \\le K \\le 5000$\n*   For each type-$1$ operation, $1 \\le x \\le 5000$.\n*   All the operations satisfy the condition in the problem statement.\n\n## Input\n\nThe input is given from Standard Input in the following format, where $\\mathrm{Query}_i$ represents the $i$\\-th operation:\n\n$Q$ $K$\n$\\rm{Query}$$_{1}$\n$\\rm{Query}$$_{2}$\n$\\vdots$\n$\\rm{Query}$$_{Q}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc321_f","tags":[],"sample_group":[["15 10\n+ 5\n+ 2\n+ 3\n- 2\n+ 5\n+ 10\n- 3\n+ 1\n+ 3\n+ 3\n- 5\n+ 1\n+ 7\n+ 4\n- 3","0\n0\n1\n0\n1\n2\n2\n2\n2\n2\n1\n3\n5\n8\n5\n\nThis input contains $15$ operations.\nAfter the last operation, the box contains the balls $(5,10,1,3,1,7,4)$.  \nThere are five ways to pick up balls for a sum of $10$:\n\n*   $5+1+3+1$ (the $1$\\-st, $3$\\-rd, $4$\\-th, $5$\\-th balls)\n*   $5+1+4$ (the $1$\\-st, $3$\\-rd, $7$\\-th balls)\n*   $5+1+4$ (the $1$\\-st, $5$\\-th, $7$\\-th balls)\n*   $10$ (the $2$\\-nd ball)\n*   $3+7$ (the $4$\\-th, $6$\\-th balls)"]],"created_at":"2026-03-03 11:01:14"}}