#P7436. 画矩形

画矩形

Description

The lord of Shandianbei Palace drew an n×mn \times m rectangular grid. Specifically, it contains all integer points with coordinates (x,y)(x,y) (x[0,n],y[0,m]x\in [0,n], y\in [0,m]), and all edges connecting pairs of points with distance 11.

Now they want to know how many rectangles with perimeter not greater than kk can be drawn inside this grid (all four sides of the rectangle must be parallel to the coordinate axes). But even as an easy warm-up problem, this would still be too simple, so they added qq obstacle points and require that the chosen rectangle does not contain any obstacle point. Each obstacle point is a 1×11\times 1 square. Now the lord of Shandianbei Palace is going to make other “easy (tricky)” problems, can you help solve this one? Output the answer modulo 998244353998244353.

Input Format

The first line contains four positive integers nn, mm, qq, and kk.

The next qq lines each contain two numbers, the xx coordinate and the yy coordinate of an obstacle (an obstacle at coordinate (x,y)(x,y) has four vertices (x1,y1),(x1,y),(x,y1),(x,y)(x-1,y-1),(x-1,y),(x,y-1),(x,y)).

Output Format

Output one line with one integer, the number of rectangles modulo 998244353998244353.

3 3 4 4
1 1
2 2
3 3
2 3
5
3 3 4 10000
1 1
2 2
3 3
2 3
8

Hint

Sample Explanation

Sample #1: All cells except the 44 obstacle cells are valid rectangles. Therefore, the answer is 3×34=53\times 3-4=5.

Sample #2: This is just counting the number of valid rectangles. There are 55 rectangles of size 1×11\times 1, and 33 rectangles in total of sizes 1×21\times 2 and 2×12\times 1, so the answer is 5+3=85+3=8.

Constraints

ID n,mn,m kk qq
1,21,2 103\le 10^3 1.5×109\le 1.5\times 10^9 =0=0
3,4,5,63,4,5,6 1.5×109\le 1.5\times 10^9
7,87,8 20\le 20 20\le 20
9,109,10 1.5×109\le 1.5\times 10^9 20\le 20
11,12,13,1411,12,13,14 105\le 10^5
15,16,17,18,19,2015,16,17,18,19,20 1.5×109\le 1.5\times 10^9

For 100%100\% of the testdata, 1n,m1.5×1091\le n,m \le 1.5\times 10^9, 4k1.5×1094\le k \le 1.5\times 10^9, 0q200\le q \le 20. It is guaranteed that all obstacles are valid and pairwise distinct.

Translated by ChatGPT 5