Jewelry Exhibition

No attempts yetTime limit1sMemory limit256 MB

Problem

To guard an art jewelry exhibition at night, a security agency installed a new laser beam system built from sender and receiver pairs. Each pair produces a strip of light of unit width and guards every object inside that strip. For each exhibition room, compute the minimum number of sender and receiver pairs that is enough to protect every exhibit in the room.

A room is a rectangle, so it is described as the [0,N]×[0,M][0, N] \times [0, M] rectangle in the plane. The objects to guard are points inside that rectangle. A sender is mounted on one wall and the matching receiver on the opposite wall, so the strip it produces is a rectangle of unit width whose length is either NN or MM. The system is still not perfect, so the corners of every strip must have integer coordinates. A pair also protects only the items inside its strip, not the ones lying on its border. For that reason the agency arranged the exhibits so that both coordinates of every exhibit point are non-integers.

The figure below shows, on the left, eight items arranged in a [0,4]×[0,4][0, 4] \times [0, 4] room. Up to eight sender and receiver pairs can be mounted in that room. The picture on the right shows the area three pairs protect.

Input

The first line contains the number of exhibition rooms RR, where R10R \le 10.

The descriptions of the RR rooms follow. Each description starts with a single line holding three integers NN, MM and KK. The values NN and MM give the size of the room, with 0<N1000 < N \le 100 and 0<M1000 < M \le 100. The value KK is the number of exhibits, with 0<K1040 < K \le 10^4. The next KK lines each contain two real numbers xx and yy, the coordinates of one exhibit. It holds that 0<x<N0 < x < N and 0<y<M0 < y < M, and neither xx nor yy is an integer.

Output

For every room print one line with one integer, the minimum number of sender and receiver pairs that is enough to protect every exhibit in that room.