Preparando MOJI
Your friend is running a flower shop. In order to be prepared for the next holidays (when, as usual, sales skyrocket) she asked you to write her a special program that will help to analyze the stocks she has.
There are $$$n$$$ different types of flowers she can order and each flower of the type $$$i$$$ costs $$$w_i$$$. The last holidays were a great success, she sold all flowers she had, so right now all her stocks are empty.
From this point, she starts routine operations of ordering and selling flowers, while trying to analyze what she has at hand. All of this can be represented as $$$m$$$ queries of three types:
Help your friend and write the program that can process all these queries.
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 1000$$$; $$$1 \le m \le 1000$$$) — the number of flower types and the number of queries.
The second line contains $$$n$$$ integers $$$w_1, w_2, \dots, w_n$$$ ($$$1 \le w_i \le 1000$$$) — the cost of one flower of each type.
The next $$$m$$$ lines contains queries — one per line. Each query has one of three types:
It's guaranteed that the total cost of all flowers in stock after each query doesn't exceed $$$5000$$$.
For each query of the third type, print how many variants of bouquets she can make using only flowers of types $$$l, l + 1, \dots, r$$$ with the total cost no more than $$$k$$$. Since the answer may be too large, print it modulo $$$998\,244\,353$$$.
5 12 1 2 3 2 1 1 1 5 1 2 3 1 3 1 3 1 5 10 3 4 5 100 1 4 4 1 5 1 3 2 5 7 3 1 1 3 3 1 5 100 2 1 5 3 1 5 100
40 0 28 3 479 79