beecrowd | 3032

Product Tuples

By Microsoft RS Serbia

Timelimit: 8

While roaming the mystic areas of Stonefalls, in order to drop legendary loot, an adventurer was given a quest as follows. He was given an array A = a1 , a2 , ..., aN of length N , and a number K.

Define array B as B(q, A) = qa1 , qa2 , ..., qaN . Define function F as F (B, K) being sum of products of all K-tuples of elements in array B. For example, if the array B is [2, 3, 4, 5], and with K = 3, sum of products of all 3-tuples is

F (B, 3) = 2 ∗ 3 ∗ 4 + 2 ∗ 3 ∗ 5 + 3 ∗ 4 ∗ 5 + 2 ∗ 4 ∗ 5

He was then given a number Q, number of queries of two types:

• Type 1: Given q, i, and d calculate F (B(q, A), K) where we make change to initial array as A[i] = d.

• Type 2: Given q, L, R, and d calculate F (B(q, A), K) where we make change to initial array as A[i] = A[i] + d for all i in range [L, R] inclusive.

All changes are temporarily made to initial array, and don’t propagate to following queries. Help the adventurer calculate the answer to a quest, and finally get that loot!

Input

In the first two lines, numbers N (1 ≤ N ≤ 2 ∗ 104 ) and K (1 ≤ KN ), the length of initial array A, and tuple size, followed by a1 , a2 , a3 , . . . , aN (0 ≤ ai ≤ 109 ) , elements of array A, in the next line. Then follows number Q (Q ≤ 10), number of queries. In the next Q lines come queries of the form:

• 1 q, i and d, for type 1,

• 2 q, L and R d, for type 2,

as explained above (0 ≤ q, d ≤ 109 , 1 ≤ i, L, RN )

Output

Print Q lines, the answers to queries, modulo 998244353.

Input Sample Output Sample

5

2

1 2 3 4 5

3

1 6 1 1

1 6 5 2

2 6 2 3 1

85
127
63