#P7245. 灯光效果

灯光效果

Description

For stage effects, lighting is an important role. The background screen is an n×nn \times n rectangle. Rows are numbered from left to right and columns are numbered from top to bottom as 1n1 \sim n. A lighting cell at row xx and column yy is denoted by (x,y)(x,y).

As the dedicated lighting designer, A-Ling wrote a program to control the background lighting effects. She sets two increasing integer sequences {xm}\{x_m\} and {ym}\{y_m\} of length mm, satisfying 0x1,y10\le x_1,y_1 and xm,ymnx_m,y_m\le n. Each time the lights change, the program uniformly randomly generates two pairs of integers (i1,i2)(i_1,i_2) and (j1,j2)(j_1,j_2), satisfying 1i1<i2m1\le i_1<i_2\le m and 1j1<j2m1\le j_1<j_2\le m, and toggles (on becomes off, off becomes on) the state of all lighting cells (r,c)(r,c) that satisfy xi1<rxi2x_{i_1}<r\le x_{i_2} and yj1<cyj2y_{j_1}<c\le y_{j_2}.

At the beginning of the performance, all lighting cells are off. After calculation, there will be a total of kk lighting changes by the end of the performance. Since the lighting effect at the curtain call is crucial, A-Ling wants to know: at the end, what is the expected number of lighting cells that are on?

Since the answer may be a decimal, to avoid precision loss, output the value of the answer modulo 998244353998244353.


Simplified Statement

There is an n×nn\times n matrix, with all elements initially equal to 00. Given increasing sequences {xm}\{x_m\} and {ym}\{y_m\}, where 0x1,y10\le x_1,y_1 and xm,ymnx_m,y_m\le n, one operation is defined as:

  • Randomly choose four integers i1,i2,j1,j2i_1,i_2,j_1,j_2 satisfying 1i1<i2m1\le i_1<i_2\le m and 1j1<j2m1\le j_1<j_2\le m.
  • XOR every element in the submatrix with top-left corner (xi1+1,yj1+1)(x_{i_1}+1,y_{j_1}+1) and bottom-right corner (xi2,yj2)(x_{i_2},y_{j_2}) by 11.

Find the expected value of the sum of all elements in the matrix after kk operations. Take the answer modulo 998244353998244353.

Input Format

The first line contains three integers n,m,kn,m,k.

The second line contains mm integers, where the ii-th number denotes xix_i.

The third line contains mm integers, where the ii-th number denotes yiy_i.

Output Format

Output one integer in one line, representing the value of the answer modulo 998244353998244353.

2 3 1
0 1 2
0 1 2

110916041
3 3 3
0 1 2
0 1 2
592921545

Hint

Sample Explanation 1

In the sample, {xm}={ym}={0,1,2}\{x_m\}=\{y_m\}=\{0,1,2\}. You can see that any submatrix of this 2×22\times 2 matrix can be toggled. When the submatrix sizes are 1,2,41,2,4, the numbers of corresponding choices are 4,4,14,4,1. Since there is only one operation, the corresponding final sums of matrix elements are 4×1,4×2,1×44\times 1,4\times 2,1\times 4. Therefore, the answer is 4+8+44+4+1=169\frac{4+8+4}{4+4+1}=\frac{16}9.

Constraints

This problem uses bundled testdata.

For 100%100\% of the data, 2mmin(n+1,103)2\le m\le \min(n+1,10^3), 1n1091\le n\le10^9, 1k1061\le k\le 10^6. It is guaranteed that xix_i are pairwise distinct and strictly increasing, and yiy_i are pairwise distinct and strictly increasing.

Subtask Score nn mm kk
1 10 4 \le 4 3 \le 3 2 \le 2
2 5 / 22 /
3 25 102 \le 10^2 / 102 \le 10^2
4 20 109 \le 10^9
5 102 \le 10^2 106 \le 10^6
6 / /

Translated by ChatGPT 5