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] 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 N or M. 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] 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.

The first line contains the number of exhibition rooms R, where R≤10.
The descriptions of the R rooms follow. Each description starts with a single line holding three integers N, M and K. The values N and M give the size of the room, with 0<N≤100 and 0<M≤100. The value K is the number of exhibits, with 0<K≤104. The next K lines each contain two real numbers x and y, the coordinates of one exhibit. It holds that 0<x<N and 0<y<M, and neither x nor y is an integer.
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.