Kangaroo Enclosure

No attempts yetTime limit1sMemory limit128 MB

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 1×11 \times 1. The meadow has WW rows of KK fields each, for a total of W×KW \times K fields.

Farmer Józef brought NN 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 ZZ (1Z101 \le Z \le 10), the number of test sets. Then ZZ sets follow.

The first line of each set contains three space-separated integers WW, KK, NN (1W,K1061 \le W, K \le 10^6, 3N1063 \le N \le 10^6): the meadow dimensions and the number of kangaroos.

Each of the next NN lines contains two space-separated integers wiw_i, kik_i (1wiW1 \le w_i \le W, 1kiK1 \le k_i \le K), where wiw_i is the row and kik_i is the column of the ii-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