Kangaroo Enclosure
Time limit1sMemory limit128 MB
Count the grid cells inside the smallest convex enclosure with horizontal, vertical, and diagonal sides that covers all marked cells.
Problem
Farmer Józef, a well-known farmer and breeder, is always looking for ways to grow his farm. This time he has decided to start raising kangaroos.
He prepared a meadow divided by a regular grid into unit fields of size . The meadow has rows of fields each, for a total of fields.
Farmer Józef brought kangaroos onto the meadow, and each one picked its own favorite field (every kangaroo a different field). He now wants to build the smallest possible enclosure that still contains the favorite fields of all the kangaroos.
The enclosure must satisfy:
- It must be a convex polygon whose boundary consists of segments joining the centers of consecutively adjacent fields. Two fields are adjacent if they share a side or a corner. (Equivalently, every edge of the polygon is horizontal, vertical, or a 45-degree diagonal.)
- It must contain the favorite fields of all kangaroos. A field is considered contained if the enclosure's boundary passes through its center, or if its center lies inside the enclosure.
Among all enclosures meeting these conditions, it must contain the fewest fields.
Write a program that computes the number of fields contained in the optimal enclosure.
Input
The first line contains an integer (), the number of test sets. Then sets follow.
The first line of each set contains three space-separated integers , , (, ): the meadow dimensions and the number of kangaroos.
Each of the next lines contains two space-separated integers , (, ), where is the row and is the column of the -th kangaroo's favorite field. All favorite fields are distinct.
Every test set describes a non-degenerate case: the polygon of the optimal enclosure has a nonzero area.
Output
For each test set, print on its own line the number of fields contained in the optimal enclosure.
Hint


