#P9563. Little Cyan Fish and Banned Points

    ID: 22710 Type: Default 1000ms 256MiB

Little Cyan Fish and Banned Points

Little Cyan Fish and Banned Points

Little Cyan Fish has an \(n \times m\) rectangle on the plane with its bottom-left corner at \( (0,0) \) and its top-right corner at \( (n,m) \). There are \(k\) banned points in the rectangle; the \(i\)-th banned point is at \( (x_i, y_i) \).

He wants to draw a square inside the rectangle. He can draw a square with its bottom-left corner at \( (x, y) \) and side length \(d\) if and only if:

  • \(x\) and \(y\) are non-negative integers and \(d\) is a positive integer.
  • \(0 \le x < x+d \le n\) and \(0 \le y < y+d \le m\).
  • For every banned point \( (x_i,y_i) \), it is NOT the case that \(x < x_i < x+d\) and \(y < y_i < y+d\). That is, banned points must not lie strictly inside the square (points on the boundary are allowed).

For each valid square, its area is \(d^2\). Your task is to compute the sum of the areas of all squares that Little Cyan Fish can possibly draw, modulo \(998244353\).

inputFormat

The first line contains three integers \(n\), \(m\) and \(k\) \((1 \leq n, m \leq 10^3, 0 \le k \leq 10^5)\) --- the dimensions of the rectangle and the number of banned points.

Then \(k\) lines follow, each containing two integers \(x_i\) and \(y_i\) representing a banned point.

Note: Banned points may lie on the boundary of the rectangle. A banned point is only problematic if it lies strictly inside a drawn square.

outputFormat

Output a single integer, the sum of the areas of all valid squares modulo \(998244353\).

sample

4 4 1
2 2
41