Bruteforce

아직 제출이 없습니다시간 제한5초메모리 제한512 MB

문제

You are given fixed integers kk and ww.

For an array aa of length nn, let us define its weight in the following way:

  • Let bb be the array aa sorted in non-descending order.
  • The weight of aa is then defined as _i=1nb_iikw\displaystyle \sum\_{i=1}^{n} \left\lfloor{\frac{b\_i \cdot i^k}{w}}\right\rfloor.

Here, x\left\lfloor x \right\rfloor is the largest integer not exceeding xx.

For example, if k=2k = 2 and w=3w = 3, then the weight of a=\[3,2,2]a = \[3, 2, 2] is equal to:

 2123+2223+3323=0+2+9=11\displaystyle \left\lfloor {\frac{2 \cdot 1^2}{3}} \right\rfloor + \left\lfloor {\frac{2 \cdot 2^2}{3}} \right\rfloor + \left\lfloor {\frac{3 \cdot 3^2}{3}} \right\rfloor = 0 + 2 + 9 = 11.

You are given an initial array aa, and will be given qq queries. Each query changes one element of array aa. After each query, you should output the new weight of the array. Since array weights can be really large, you should output them modulo 998,244,353998\\,244\\,353.

Note that the changes persist between queries. For example, the second query is applied to the array which is already changed by the first query.

입력

The first line contains three integers nn, kk, ww (1n1051 \le n \le 10^5, 1k51 \le k \le 5, 1w51 \le w \le 5): the length of the array and the parameters from the statement.

The second line contains nn integers a_ia\_i (0a_i1050 \le a\_i \le 10^5): the elements of the original array.

The third line contains a single integer qq (1q1051 \le q \le 10^5): the number of queries.

Each of the next qq lines contains two integers, pos\mathit{pos} and xx (1posn1 \le \mathit{pos} \le n, 0x1050 \le x \le 10^5). This describes a query that changes a_posa\_{\mathit{pos}} into xx.

출력

Output qq integers: the weights of the array after each change, modulo 998,244,353998\\,244\\,353.