Rikka with Storehouse

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

문제

On activities held by Algorithm Association, lemon teas are provided to the participants almost infinitely. To store such a large number of lemon teas, Rikka wants to build some storehouses.

Rikka plans to build N=2n1N=2^n-1 storehouses, together with N1N-1 bidirectional roads. The ii-th road connects the (i+1)(i+1)-th storehouse and the i2\lceil \frac{i}{2} \rceil-th storehouse.

These storehouses will be built on an uneven piece of land. For each i\[N2,N]i \in \[\lceil \frac{N}{2} \rceil, N], the altitude of the ii-th storehouse is known to be a_ia\_i. Rikka can choose the altitudes for other storehouses arbitrarily. (The value of altitude can be any real number).

Carrying lemon teas on a steep hill is difficult. Rikka wants to make the road system as convenient as possible. Therefore, Rikka wants to minimize the square sum of the altitude difference of each road, i.e. ans=min_a_1,,a_N2R_i=1N1(a_i+1a_i2)2ans = \min\_{a\_1, \dots, a\_{\lfloor \frac{N}{2} \rfloor} \in \mathbb R} \sum\_{i=1}^{N-1} \left( a\_{i+1} - a\_{\lceil \frac{i}{2} \rceil}\right)^2

Due to the geological movement, the altitude of the last N2\lceil \frac{N}{2} \rceil storehouses often changes. Lucky, it is free for Rikka to change the altitude of the first N2\lfloor \frac{N}{2} \rfloor storehouses at any time.

Your task is to help Rikka to find out the optimal plan after each change.

입력

The first line contains two integers n,m (2n18,0m2×105)n,m\ (2 \leq n \leq 18, 0 \leq m \leq 2 \times 10^5).

The second line contains N2\lceil \frac{N}{2} \rceil integers h_i (1h_i108)h\_i\ (1 \leq h\_i \leq 10^8), representing a_N2,,a_Na\_{\lceil \frac{N}{2} \rceil}, \dots, a\_{N} in order, where N=2n1N = 2^n-1

Then mm lines follow, each line with two integers x_i,w_i (N2x_in,1w_i108)x\_i, w\_i\ (\lceil \frac{N}{2} \rceil \leq x\_i \leq n, 1 \leq w\_i \leq 10^8), representing the altitude of the x_ix\_i-th storehouse is changed to w_iw\_i during the ii-th movement.

출력

Output m+1m+1 lines, each with a single number: the initial value of ansans followed by the value of ansans after each movement.

Writing a special judge is a tiring task. Therefore, you are required to output the answer module 998244353998244353. Formally, if the simplest fraction representation of ansans is xy\frac{x}{y}, you need to output x×y998244351 mod 998244353x \times y^{998244351} \text{ mod } 998244353.

힌트

For the first sample, one optimal solution is a_1=2a\_1=2 and the value of ansans is (21)2+(23)2=2(2-1)^2 + (2-3)^2 = 2.