#P8576. 「DTOI-2」星之界

「DTOI-2」星之界

Background

Celestials open the blue heavens, and the silver realm loses the dusk.

Problem Description

The stars in the night sky form a sequence aa. The ii-th number in the sequence represents the brightness of the ii-th star.

Now, as the favored one of the stars, you have two ways to operate on the stars.

  • Operation 1: The input format is 1 l r x y\texttt{1 l r x y}, which means changing the brightness of all stars in [l,r][l,r] whose brightness is xx to yy.

  • Operation 2: The input format is 2 l r\texttt{2 l r}, which means outputting the value of $\prod\limits_{i = l}^{r} C_{\sum_{j = l}^{i}a_j}^{a_i}\ \bmod 998244353$.

Input Format

The first line contains two integers n,qn,q, representing the length of the sequence and the number of operations.

The second line contains nn integers, representing the initial values of the sequence.

The next qq lines each contain one operation, with the format given above.

Output Format

For each operation of type 22, output the required value.

3 3
2 3 5
2 1 3
1 1 3 2 4
2 1 2
2520
35
5 5
4 6 7 8 9
1 2 4 9 8
1 3 5 8 9
2 3 5
2 1 3
2 1 2
412013881
4084080
210

Hint

Sample Explanation #1

It can be obtained by directly computing according to the statement.

Subtask\textbf{Subtask} nn \le qq \le Special Property Total Score
11 1010 1515 None 55
22 10310^3 1010
33 5×1045\times 10^4 Only operation 22
44 Only one operation 22
55 None 2121
66 10510^5 a[i]5×105\sum a[i] \le 5\times 10^5 1414
77 None 3030

For 100%100\% of the testdata, 1n,q,ai1051 \le n,q,a_i \le 10^5. Also, 1l,rn;1x,y1051 \le l,r\le n;1 \le x,y\le 10^5.

At any time, a\sum a will not exceed 10710^7.

Translated by ChatGPT 5