Consider a square chessboard with cells and queens on the chessboard (Note: there are no other chess pieces besides the queens).
A queen can move vertically, horizontally or diagonally. As an example, consider the square chessboard with cells with one queen (denoted by the ♕
notation) in Figure 1 below. The cells that can be reached by the queen are marked with the ◯
notation. There are cells that cannot be reached by the queen.
Your task is to calculate the number of cells that are NOT reachable by any queens.
Input Specification
The first line contains two integers, and . Following are lines. Each line contains two integers and , representing the location of a queen, i.e., the queen is at th row and th column .
Output Specification
The number of cells that are not reachable by any queens.
Sample Input 1
6 1
4 3
Output for Sample Input 1
16
Sample Input 2
6 2
4 3
6 4
Output for Sample Input 2
9
Explanation
Figure 1 and Figure 2 correspond to Sample 1 and Sample 2, respectively.
Comments
This comment is hidden due to too much negative feedback. Show it anyway.