Problem8824--[yosupo] Data Structure - Point Set Range Composite

8824: [yosupo] Data Structure - Point Set Range Composite

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

Given a size $N$ sequence of linear functions $f_0, f_1, ..., f_{N-1}$. For all $i$, $f_i(x) = a_i x + b_i$. Process $Q$ queries as follows:

- 0 $p$ $c$ $d$: change $f_p \gets cx + d$.
- 1 $l$ $r$ $x$: print $f_{r-1}(f_{r-2}(...f_l(x))) \bmod 998244353$.

Input

$N$ $Q$
$a_0$ $b_0$
$a_1$ $b_1$
:
$a_{N - 1}$ $b_{N - 1}$
$\textrm{Query}_0$
$\textrm{Query}_1$
:
$\textrm{Query}_{Q - 1}$

Constraints

$1 \leq N, Q \leq 500,000$
$1 \leq a_i, c < 998244353$
$0 \leq b_i, d, x < 998244353$
$0 \leq p < N$
$0 \leq l < r \leq N$

Sample 1 Input

5 5
1 2
3 4
5 6
7 8
9 10
1 0 5 11
1 2 4 12
0 1 13 14
1 0 4 15
1 2 5 16

Sample 1 Output

14005
470
8275
5500

HINT

相同题目:yosupo

Source/Category