Neighbors#5475

Neighbors

3 seconds
64 megabytes
Hard

Consider a rectangle on the Cartesian plane with vertices at and , where and are positive integers. Within this rectangle, there are mountain peaks located at grid points, which are points with integer coordinates. Each person wants to build a house, but the following rules apply:

Thus, there are (w+1)\times(h+1)-N possible locations for houses. Some locations are more desirable than others. A grid point is said to have a northern neighbor if there is a peak at (x, y+d), where is a positive integer. Similarly, southern, eastern, and western neighbors are defined. Therefore, each grid point that is not a peak can have between and neighbors. The more neighbors a location has, the more desirable it is. Your task is to count how many grid points (excluding peaks) have exactly , , , , or neighbors.

Write a program that:

Input

The first line contains three integers , , (1 \leq w, h \leq 10^9), (1 \leq N \leq 500000), separated by spaces. The next lines each contain two integers and (0 \leq x \leq w), (0 \leq y \leq h), separated by a space, representing the locations of the peaks. All peaks are at distinct points.

Output

The output should be a single line containing integers, separated by spaces, representing the number of grid points (excluding peaks) that have exactly , , , , and neighbors, respectively.

Examples

Example 1

Loading
Loading