#P7504. [2017年杭电多校]Destroy the cube
[2017年杭电多校]Destroy the cube
Destroy the cube
Problem Description
There is a chessboard with rows and columns, every position is black or white. It is defined that means the color of the position in the th row and the th column, and it is guaranteed that for any , which shows it is quite symmetry. Also because of this, only the colors of the positions which satisfies are given, and the number of the given black position is in total. Now HazelFan has a big cube with layers and rows and lines, and its six sides are all same as the chessboard. For the three pairs of opposite sides, for each black position on one side, he will dig through the cube from the position straight to a black position on the other side. Please tell him after he destroys the cube, how many little cubes are left.
Input
The first line contains a positive integer , denoting the number of test cases. For each test case: The first line contains two positive integers $n,t(1\leq n\leq6\times10^4,1\leq t\leq1.2\times10^5)$. The next lines, each line contains two positive integers , denoting a given black position.
Output
For each test case: A single line contains a nonnegative integer, denoting the answer.
Sample Input
2
3 1
2 2
5 2
2 3
3 3
Sample Output
20
76
Source
2017 Multi-University Training Contest - Team 7